[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kmuddy] /: more qt5/kf5 migration
From: Tomas Mecir <null () kde ! org>
Date: 2018-03-31 19:47:15
Message-ID: E1f2MT5-0001ET-RV () code ! kde ! org
[Download RAW message or body]
Git commit fc4fafad4772f0feac29eae250be2febcf8dccbd by Tomas Mecir.
Committed on 31/03/2018 at 19:46.
Pushed by mecir into branch 'master'.
more qt5/kf5 migration
M +2 -2 CMakeLists.txt
M +2 -0 kmuddy/ctranscript.cpp
M +1 -4 kmuddy/cwindowlist.cpp
M +1 -1 kmuddy/dialogs/CMakeLists.txt
M +0 -2 kmuddy/dialogs/cdirlist.cpp
M +8 -38 kmuddy/dialogs/dlgappsettings.cpp
M +0 -4 kmuddy/dialogs/dlgappsettings.h
M +24 -21 kmuddy/dialogs/dlgconnect.cpp
M +3 -2 kmuddy/dialogs/dlgconnect.h
M +11 -11 kmuddy/dialogs/dlgdumpbuffer.cpp
M +3 -2 kmuddy/dialogs/dlgdumpbuffer.h
M +21 -23 kmuddy/dialogs/dlgeditprofile.cpp
M +3 -2 kmuddy/dialogs/dlgeditprofile.h
M +7 -6 kmuddy/dialogs/dlggrabkey.cpp
M +3 -2 kmuddy/dialogs/dlggrabkey.h
M +30 -27 kmuddy/dialogs/dlgimportexportprofile.cpp
M +6 -5 kmuddy/dialogs/dlgimportexportprofile.h
M +10 -9 kmuddy/dialogs/dlgmudlist.cpp
M +3 -2 kmuddy/dialogs/dlgmudlist.h
M +0 -2 kmuddy/dialogs/dlgmultiline.cpp
M +1 -0 kmuddy/dialogs/dlgmultiline.h
M +5 -2 kmuddy/dialogs/dlgmxpconsole.cpp
M +1 -0 kmuddy/dialogs/dlgmxpconsole.h
M +7 -4 kmuddy/dialogs/dlgobjects.cpp
M +3 -2 kmuddy/dialogs/dlgobjects.h
M +10 -11 kmuddy/dialogs/dlgoutputwindow.cpp
M +3 -2 kmuddy/dialogs/dlgoutputwindow.h
M +7 -5 kmuddy/dialogs/dlgprofilesettings.cpp
M +1 -0 kmuddy/dialogs/dlgprofilesettings.h
M +7 -5 kmuddy/dialogs/dlgquickconnect.cpp
M +3 -2 kmuddy/dialogs/dlgquickconnect.h
M +0 -2 kmuddy/dialogs/dlgstatistics.cpp
M +6 -4 kmuddy/dialogs/dlgtranscript.cpp
M +1 -0 kmuddy/dialogs/dlgtranscript.h
M +7 -5 kmuddy/dialogs/dlgwindows.cpp
M +4 -4 kmuddy/dialogs/dlgwindows.h
M +2 -2 kmuddy/kmuddy.cpp
M +1 -1 libs/CMakeLists.txt
M +1 -1 libs/arith-exp.cpp
M +1 -2 libs/caliaseditor.cpp
M +1 -2 libs/cansiparser.cpp
M +1 -1 libs/cansiparser.h
M +1 -1 libs/ccmdparser.cpp
M +1 -1 libs/ccmdparser.h
M +3 -3 libs/ccmdprocessor.cpp
M +1 -1 libs/ccmdprocessor.h
M +0 -1 libs/ccmdqueues.cpp
M +2 -2 libs/ccmdqueues.h
M +185 -1330 libs/cconsole.cpp
M +28 -201 libs/cconsole.h
M +0 -2 libs/cdownloader.cpp
M +1 -1 libs/cexpresolver.cpp
M +5 -9 libs/cglobalsettings.cpp
M +8 -10 libs/cinputline.cpp
M +7 -7 libs/cinputline.h
M +13 -13 libs/clist.cpp
M +5 -6 libs/clisteditor.cpp
M +1 -1 libs/clistgroup.cpp
M +5 -5 libs/clistgroup.h
M +0 -2 libs/clistgroupeditor.cpp
M +2 -2 libs/clistmanager.h
M +0 -1 libs/clistobject.cpp
M +6 -7 libs/clistviewer.cpp
M +1 -1 libs/cmsp.cpp
M +26 -7 libs/coutput.cpp
M +14 -3 libs/coutput.h
M +0 -1 libs/cplugin.cpp
M +3 -3 libs/cpluginmanager.cpp
M +5 -5 libs/cprofilemanager.cpp
M +0 -2 libs/cprompt.cpp
M +0 -2 libs/cscripteditor.cpp
M +0 -1 libs/cscripteval.cpp
M +14 -37 libs/csoundplayer.cpp
M +3 -3 libs/csoundplayer.h
M +1 -3 libs/cstatus.cpp
M +3 -3 libs/cstatus.h
M +12 -10 libs/ctextchunk.cpp
M +40 -43 libs/ctextchunk.h
M +1 -1 libs/cvariablelist.cpp
M +3 -4 libs/kmuddy_export.h
https://commits.kde.org/kmuddy/fc4fafad4772f0feac29eae250be2febcf8dccbd
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dbd64c0..6edfea2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,8 @@ include(FeatureSummary)
include(KDEFrameworkCompilerSettings)
include(ECMInstallIcons)
-find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Script)
-find_package(KF5 REQUIRED COMPONENTS Config CoreAddons I18n KIO KDELibs4Support \
XmlGui Parts Service) +find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Script \
Multimedia) +find_package(KF5 REQUIRED COMPONENTS Config CoreAddons WidgetsAddons \
I18n KIO KDELibs4Support KCMUtils XmlGui Parts Service)
find_package(MXP)
if (MXP_FOUND)
diff --git a/kmuddy/ctranscript.cpp b/kmuddy/ctranscript.cpp
index dae345f..e75f347 100644
--- a/kmuddy/ctranscript.cpp
+++ b/kmuddy/ctranscript.cpp
@@ -117,6 +117,7 @@ void cTranscript::addLineToTranscript (cTextChunk *chunk)
case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap); break;
case TRANSCRIPT_HTML: s = chunk->toHTML (); break;
};
+ s += "\n"; // we use <pre> in HTML, so this applies equally to all three
QByteArray b = s.toLocal8Bit ();
const char *ch = b.constData();
if (ch)
@@ -144,6 +145,7 @@ void cTranscript::addLineToAdvTranscript (cTextChunk *chunk)
case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap); break;
case TRANSCRIPT_HTML: s = chunk->toHTML (); break;
};
+ s += "\n"; // we use <pre> in HTML, so this applies equally to all three
QByteArray b = s.toLocal8Bit ();
const char *ch = b.constData();
if (ch)
diff --git a/kmuddy/cwindowlist.cpp b/kmuddy/cwindowlist.cpp
index 2a3536f..df9e6a7 100644
--- a/kmuddy/cwindowlist.cpp
+++ b/kmuddy/cwindowlist.cpp
@@ -235,16 +235,13 @@ void cWindowList::adjustFonts(QFont font)
}
}
-void cWindowList::applySettings (bool allowblinking, bool wordwrapping,
- int wrappos, int indentvalue, int forceredraw)
+void cWindowList::applySettings (bool allowblinking, int indentvalue, int \
forceredraw) {
map<QString, dlgOutputWindow *>::iterator it;
for (it = windows.begin(); it != windows.end(); ++it)
{
cConsole *console = it->second->console();
console->setEnableBlinking (allowblinking);
- console->setWordWrapping (wordwrapping);
- console->setWrapPos (wrappos);
console->setIndentation (indentvalue);
console->setRepaintCount (forceredraw);
}
diff --git a/kmuddy/dialogs/CMakeLists.txt b/kmuddy/dialogs/CMakeLists.txt
index ccb2d09..242d480 100644
--- a/kmuddy/dialogs/CMakeLists.txt
+++ b/kmuddy/dialogs/CMakeLists.txt
@@ -29,5 +29,5 @@ set(dialogs_LIB_SRCS
add_library(dialogs STATIC ${dialogs_LIB_SRCS})
-target_link_libraries(dialogs )
+target_link_libraries(dialogs KF5::I18n Qt5::Widgets KF5::WidgetsAddons)
diff --git a/kmuddy/dialogs/cdirlist.cpp b/kmuddy/dialogs/cdirlist.cpp
index 62c7ea8..0de5f03 100644
--- a/kmuddy/dialogs/cdirlist.cpp
+++ b/kmuddy/dialogs/cdirlist.cpp
@@ -135,5 +135,3 @@ void cDirList::update ()
listbox->setCurrentRow (item);
}
-#include "cdirlist.moc"
-
diff --git a/kmuddy/dialogs/dlgappsettings.cpp b/kmuddy/dialogs/dlgappsettings.cpp
index f23269e..838c927 100644
--- a/kmuddy/dialogs/dlgappsettings.cpp
+++ b/kmuddy/dialogs/dlgappsettings.cpp
@@ -57,9 +57,8 @@ dlgAppSettings::dlgAppSettings (QWidget *parent) : KPageDialog \
(parent) i18n("Bright cyan"), i18n("White") };
//initial dialog size
- setInitialSize (QSize (600, 400));
- setCaption (i18n ("Application settings"));
- setButtons (KDialog::Ok | KDialog::Cancel | KDialog::Apply);
+ setWindowTitle (i18n ("Application settings"));
+ setStandardButtons (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | \
QDialogButtonBox::Apply); setFaceType (KPageDialog::List);
//prepare dialog pages
@@ -222,16 +221,8 @@ dlgAppSettings::dlgAppSettings (QWidget *parent) : KPageDialog \
(parent)
//blinking
chkblinking = new QCheckBox (i18n ("Enable b&linking"), output1);
- chkblinking->setWhatsThis( i18n ("Enables support for blinking. "
- "This is disabled by default, because most players don't like it."));
+ chkblinking->setWhatsThis( i18n ("Enables support for blinking. "));
- //word wrapping
- chkwrap = new QCheckBox (i18n ("Enable &word wrapping"), output1);
- chkwrap->setWhatsThis( i18n ("If a line that is longer than current console "
- "width is to be displayed, it wraps to the next line. With this option "
- "enabled, whole words will move to the next line, instead of cutting "
- "words in the middle."));
-
//indentation
edindent = new KIntNumInput (output2);
edindent->setLabel (i18n ("&Indentation"),
@@ -570,6 +561,11 @@ dlgAppSettings::~dlgAppSettings()
cDialogList::self()->removeDialog ("app-prefs");
}
+QSize dlgConnect::sizeHint() const
+{
+ return QSize (600, 400);
+}
+
void dlgAppSettings::showSettingsDialog ()
{
//so first we have to create the dialog...
@@ -620,16 +616,6 @@ void dlgAppSettings::setMessages (bool value)
chkmessages->setChecked (value);
}
-void dlgAppSettings::setWordWrapping (bool value)
-{
- chkwrap->setChecked (value);
-}
-
-bool dlgAppSettings::wordWrapping ()
-{
- return chkwrap->isChecked ();
-}
-
void dlgAppSettings::setIndentation (int value)
{
edindent->setValue (value);
@@ -640,16 +626,6 @@ int dlgAppSettings::indentation ()
return edindent->value ();
}
-void dlgAppSettings::setWrapPos (int value)
-{
- edwrappos->setValue (value);
-}
-
-int dlgAppSettings::wrapPos ()
-{
- return edwrappos->value ();
-}
-
void dlgAppSettings::setHistory (int value)
{
edhistory->setValue (value);
@@ -1079,9 +1055,7 @@ void dlgAppSettings::getSettingsFromDialog ()
gs->setBool ("allow-blink", enableBlinking ());
gs->setBool ("command-echo", cmdEcho ());
gs->setBool ("show-messages", messages ());
- gs->setBool ("word-wrap", wordWrapping ());
gs->setInt ("indent", indentation ());
- gs->setInt ("wrap-pos", wrapPos ());
gs->setInt ("history-size", history ());
gs->setInt ("force-redraw", forceRedraw ());
@@ -1160,9 +1134,7 @@ void dlgAppSettings::putSettingsToDialog ()
setEnableBlinking (gs->getBool ("allow-blink"));
setCmdEcho (gs->getBool ("command-echo"));
setMessages (gs->getBool ("show-messages"));
- setWordWrapping (gs->getBool ("word-wrap"));
setIndentation (gs->getInt ("indent"));
- setWrapPos (gs->getInt ("wrap-pos"));
setHistory (gs->getInt ("history-size"));
setForceRedraw (gs->getInt ("force-redraw"));
@@ -1209,5 +1181,3 @@ void dlgAppSettings::putSettingsToDialog ()
//--- NOTHING NEEDED ---
}
-#include "dlgappsettings.moc"
-
diff --git a/kmuddy/dialogs/dlgappsettings.h b/kmuddy/dialogs/dlgappsettings.h
index 1148f55..3a33af4 100644
--- a/kmuddy/dialogs/dlgappsettings.h
+++ b/kmuddy/dialogs/dlgappsettings.h
@@ -77,12 +77,8 @@ public:
void setMessages (bool value);
bool enableBlinking ();
void setEnableBlinking (bool value);
- void setWordWrapping (bool value);
- bool wordWrapping ();
void setIndentation (int value);
int indentation ();
- void setWrapPos (int value);
- int wrapPos ();
void setHistory (int value);
int history ();
int forceRedraw ();
diff --git a/kmuddy/dialogs/dlgconnect.cpp b/kmuddy/dialogs/dlgconnect.cpp
index 05eac17..1e4a2b8 100644
--- a/kmuddy/dialogs/dlgconnect.cpp
+++ b/kmuddy/dialogs/dlgconnect.cpp
@@ -24,6 +24,7 @@
#include "cprofilesettings.h"
#include <QCheckBox>
+#include <QDialogButtonBox>
#include <QGridLayout>
#include <QTreeView>
#include <QVBoxLayout>
@@ -33,21 +34,15 @@
#include <kmessagebox.h>
#include <kpushbutton.h>
-dlgConnect::dlgConnect(QWidget *parent) : KDialog (parent)
+dlgConnect::dlgConnect(QWidget *parent) : QDialog (parent)
{
- //initial dialog size
- setInitialSize (QSize (500, 400));
- setCaption (i18n ("Connect"));
- setButtons (KDialog::Ok | KDialog::Cancel);
+ setWindowTitle (i18n ("Connect"));
//create main dialog's widget
- QWidget *page = new QWidget (this);
- QGridLayout *layout = new QGridLayout (page);
-
- setMainWidget (page);
+ QGridLayout *layout = new QGridLayout (this);
//put some widgets there
- lw = new QTreeView (page);
+ lw = new QTreeView (this);
lw->setModel (cProfileManager::self()->model());
lw->setUniformRowHeights (true);
lw->setRootIsDecorated (false);
@@ -56,7 +51,7 @@ dlgConnect::dlgConnect(QWidget *parent) : KDialog (parent)
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 (page);
+ QWidget *vb = new QWidget (this);
QVBoxLayout *vblayout = new QVBoxLayout (vb);
vblayout->setSpacing (5);
KPushButton *addButton = new KPushButton (i18n ("&New profile"), vb);
@@ -68,17 +63,27 @@ dlgConnect::dlgConnect(QWidget *parent) : KDialog (parent)
vblayout->addWidget (deleteButton);
vblayout->addWidget (duplicateButton);
- chkSendNothing = new QCheckBox (i18n ("Do not &send login sequence"), page);
+ chkSendNothing = new QCheckBox (i18n ("Do not &send login sequence"), this);
chkSendNothing->setWhatsThis( i18n ("Login sequence won't be sent for "
"this connect. Useful when you're creating a new character and you "
"want to use QuickConnect for some reason."));
chkSendNothing->setChecked (false);
- chkOffline = new QCheckBox (i18n ("&Offline editing"), page);
+ chkOffline = new QCheckBox (i18n ("&Offline editing"), this);
chkOffline->setWhatsThis( i18n ("This allows offline editing of "
"profiles."));
chkOffline->setChecked(false);
+ QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | \
QDialogButtonBox::Cancel, this); + QPushButton *button = buttons->button \
(QDialogButtonBox::Ok); + button->setText (i18n ("&Connect"));
+ button->setToolTip (i18n ("Establishes connection with specified parameters."));
+ button = buttons->button (QDialogButtonBox::Cancel);
+ button->setText (i18n ("C&lose"));
+ button->setToolTip (i18n ("Closes this dialog box without connecting."));
+ connect (buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
+ connect (buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
+
layout->setRowStretch (0, 0);
layout->setRowStretch (1, 5);
layout->setSpacing (5);
@@ -87,14 +92,8 @@ dlgConnect::dlgConnect(QWidget *parent) : KDialog (parent)
layout->addWidget (vb, 0, 1);
layout->addWidget (chkSendNothing, 2, 0);
layout->addWidget (chkOffline, 3, 0);
+ layout->addWidget (buttons, 4, 0, 2, 1);
- //update button text
- setButtonText (KDialog::Ok, i18n ("&Connect"));
- setButtonToolTip (KDialog::Ok, i18n ("Establishes connection with specified \
parameters."));
- setButtonText (KDialog::Cancel, i18n ("C&lose"));
- setButtonToolTip (KDialog::Cancel, i18n ("Closes this dialog box without \
connecting."));
- showButtonSeparator (true);
-
//connect signals
connect (addButton, SIGNAL(clicked()), this, SLOT(addPressed()));
connect (modifyButton, SIGNAL(clicked()), this, SLOT(modifyPressed()));
@@ -111,6 +110,11 @@ dlgConnect::~dlgConnect()
{
}
+QSize dlgConnect::sizeHint() const
+{
+ return QSize (500, 400);
+}
+
QString dlgConnect::selectedProfile ()
{
QItemSelection sel = lw->selectionModel()->selection();
@@ -259,4 +263,3 @@ void dlgConnect::doModify ()
updateProfileFromDialog (profile);
}
-#include "dlgconnect.moc"
diff --git a/kmuddy/dialogs/dlgconnect.h b/kmuddy/dialogs/dlgconnect.h
index 46699fd..d420442 100644
--- a/kmuddy/dialogs/dlgconnect.h
+++ b/kmuddy/dialogs/dlgconnect.h
@@ -19,7 +19,7 @@
#ifndef DLGCONNECT_H
#define DLGCONNECT_H
-#include <kdialog.h>
+#include <QDialog>
#include <QItemSelection>
#include <QModelIndex>
@@ -34,12 +34,13 @@ Connect dialog. Shown and handled by cConnection.
*@author Tomas Mecir
*/
-class dlgConnect : public KDialog {
+class dlgConnect : public QDialog {
Q_OBJECT
public:
dlgConnect (QWidget *parent=0);
~dlgConnect ();
+ virtual QSize sizeHint() const override;
QString selectedProfile ();
bool sendNothing ();
bool isOffLine ();
diff --git a/kmuddy/dialogs/dlgdumpbuffer.cpp b/kmuddy/dialogs/dlgdumpbuffer.cpp
index 7bc6c19..524235b 100644
--- a/kmuddy/dialogs/dlgdumpbuffer.cpp
+++ b/kmuddy/dialogs/dlgdumpbuffer.cpp
@@ -30,27 +30,23 @@
#include <klineedit.h>
#include <klocale.h>
-dlgDumpBuffer::dlgDumpBuffer (QWidget *parent) : KDialog (parent)
+dlgDumpBuffer::dlgDumpBuffer (QWidget *parent) : QDialog (parent)
{
//initial dialog size
- setInitialSize (QSize (300, 100));
- setCaption (i18n ("Dump output buffer"));
+ setWindowTitle (i18n ("Dump output buffer"));
setButtons (KDialog::Ok | KDialog::Cancel);
//create main dialog's widget
- QWidget *page = new QWidget (this);
- QVBoxLayout *layout = new QVBoxLayout (page);
-
- setMainWidget (page);
+ QVBoxLayout *layout = new QVBoxLayout (this);
//where to start?
- chkcurpos = new QCheckBox (i18n ("&Start at current position"), page);
+ chkcurpos = new QCheckBox (i18n ("&Start at current position"), this);
chkcurpos->setWhatsThis( i18n ("When this is enabled, only the "
"part of history buffer from currently displayed part up to the end of "
"buffer will be dumped. Otherwise entire buffer will be dumped (default)."));
//the file name
- QFrame *fileframe = new QFrame (page);
+ QFrame *fileframe = new QFrame (this);
QHBoxLayout *filelayout = new QHBoxLayout (fileframe);
QLabel *lblname = new QLabel (i18n ("&File:"), fileframe);
fname = new KLineEdit (fileframe);
@@ -63,7 +59,7 @@ dlgDumpBuffer::dlgDumpBuffer (QWidget *parent) : KDialog (parent)
filelayout->addWidget (filebutton);
//type
- QFrame *typeframe = new QFrame (page);
+ QFrame *typeframe = new QFrame (this);
QHBoxLayout *typelayout = new QHBoxLayout (typeframe);
QLabel *lbltype = new QLabel (i18n ("&Dump format:"), typeframe);
ttype = new QComboBox (typeframe);
@@ -99,6 +95,11 @@ dlgDumpBuffer::~dlgDumpBuffer ()
}
+QSize dlgDumpBuffer::sizeHint() const
+{
+ return QSize (300, 100);
+}
+
void dlgDumpBuffer::browseFiles ()
{
fname->setText (KFileDialog::getSaveFileName ());
@@ -156,4 +157,3 @@ void dlgDumpBuffer::setType (int t)
ttype->setCurrentIndex (t - 1);
}
-#include "dlgdumpbuffer.moc"
diff --git a/kmuddy/dialogs/dlgdumpbuffer.h b/kmuddy/dialogs/dlgdumpbuffer.h
index 5911873..278e92d 100644
--- a/kmuddy/dialogs/dlgdumpbuffer.h
+++ b/kmuddy/dialogs/dlgdumpbuffer.h
@@ -19,7 +19,7 @@
#define DLGDUMPBUFFER_H
#include <qwidget.h>
-#include <kdialog.h>
+#include <QDialog>
class QCheckBox;
class QComboBox;
@@ -30,11 +30,12 @@ Dump Buffer dialog.
*@author Tomas Mecir
*/
-class dlgDumpBuffer : public KDialog {
+class dlgDumpBuffer : public QDialog {
Q_OBJECT
public:
dlgDumpBuffer (QWidget *parent=0);
~dlgDumpBuffer ();
+ virtual QSize sizeHint() const override;
bool curPos ();
QString fileName ();
void setFileName (const QString &fName);
diff --git a/kmuddy/dialogs/dlgeditprofile.cpp b/kmuddy/dialogs/dlgeditprofile.cpp
index 9b89902..25daaff 100644
--- a/kmuddy/dialogs/dlgeditprofile.cpp
+++ b/kmuddy/dialogs/dlgeditprofile.cpp
@@ -35,44 +35,39 @@
#include <kmessagebox.h>
#include <ktextedit.h>
-dlgEditProfile::dlgEditProfile(QWidget *parent) : KDialog (parent)
+dlgEditProfile::dlgEditProfile(QWidget *parent) : QDialog (parent)
{
- //initial dialog size
- setInitialSize (QSize (350, 350));
- setCaption (i18n ("Edit profile"));
+ setWindowTitle (i18n ("Edit profile"));
setButtons (KDialog::Ok | KDialog::Cancel);
//create main dialog's widget
- QWidget *page = new QWidget (this);
- QGridLayout *layout = new QGridLayout (page);
-
- setMainWidget (page);
+ QGridLayout *layout = new QGridLayout (this);
// create the button that opens the MUD listing
- QPushButton *btlist = new QPushButton (i18n ("&Select from MUD list"), page);
+ QPushButton *btlist = new QPushButton (i18n ("&Select from MUD list"), this);
connect (btlist, SIGNAL (clicked()), this, SLOT (openMudList()));
// put some edit boxes there
- QLabel *l1 = new QLabel (i18n ("Profile &name:"), page);
- ed1 = new KLineEdit (page);
+ QLabel *l1 = new QLabel (i18n ("Profile &name:"), this);
+ ed1 = new KLineEdit (this);
ed1->setWhatsThis( i18n ("Enter profile name here. You can enter any "
"name, but it must be <b>unique</b>."));
- QLabel *l2 = new QLabel (i18n ("&Server:"), page);
- ed2 = new KLineEdit (page);
+ QLabel *l2 = new QLabel (i18n ("&Server:"), this);
+ ed2 = new KLineEdit (this);
ed2->setWhatsThis( i18n ("Enter address of the server where your MUD is \
running."));
- QLabel *l3 = new QLabel (i18n ("&Port:"), page);
- ed3 = new KRestrictedLine (page);
+ QLabel *l3 = new QLabel (i18n ("&Port:"), this);
+ ed3 = new KRestrictedLine (this);
ed3->setValidChars ("0123456789");
ed3->setWhatsThis( i18n ("Enter port on which your MUD running (usually some \
4-digit number)."));
- QLabel *l4 = new QLabel (i18n ("&Login name:"), page);
- ed4 = new KLineEdit (page);
+ QLabel *l4 = new QLabel (i18n ("&Login name:"), this);
+ ed4 = new KLineEdit (this);
ed4->setWhatsThis( i18n ("Enter your login name on the MUD here.<p><i>This setting \
is optional.</i>"));
- QLabel *l5 = new QLabel (i18n ("Pass&word:"), page);
- ed5 = new KLineEdit (page);
+ QLabel *l5 = new QLabel (i18n ("Pass&word:"), this);
+ ed5 = new KLineEdit (this);
ed5->setEchoMode (KLineEdit::Password);
ed5->setWhatsThis( i18n ("Enter your password on the MUD here.<p><i>This setting \
is optional.</i>"));
- QLabel *l6 = new QLabel (i18n ("&Connect sequence"), page);
- connstr = new KTextEdit (page);
+ QLabel *l6 = new QLabel (i18n ("&Connect sequence"), this);
+ connstr = new KTextEdit (this);
connstr->setAcceptRichText (false);
connstr->setWordWrapMode (QTextOption::NoWrap);
connstr->setWhatsThis( i18n ("Commands to be sent to the MUD after "
@@ -114,6 +109,11 @@ dlgEditProfile::~dlgEditProfile()
//nothing here
}
+QSize dlgEditProfile::sizeHint() const
+{
+ return QSize (350, 350);
+}
+
QString dlgEditProfile::name ()
{
return ed1->text ();
@@ -207,5 +207,3 @@ void dlgEditProfile::slotOk ()
}
}
-#include "dlgeditprofile.moc"
-
diff --git a/kmuddy/dialogs/dlgeditprofile.h b/kmuddy/dialogs/dlgeditprofile.h
index d783e2a..e9378df 100644
--- a/kmuddy/dialogs/dlgeditprofile.h
+++ b/kmuddy/dialogs/dlgeditprofile.h
@@ -19,7 +19,7 @@
#ifndef DLGEDITPROFILE_H
#define DLGEDITPROFILE_H
-#include <kdialog.h>
+#include <QDialog>
class KLineEdit;
class KTextEdit;
@@ -30,12 +30,13 @@ Dialog used to edit basic profile settings (server, port, ...)
*@author Tomas Mecir
*/
-class dlgEditProfile : public KDialog {
+class dlgEditProfile : public QDialog {
Q_OBJECT
public:
dlgEditProfile (QWidget *parent=0);
~dlgEditProfile();
+ virtual QSize sizeHint() const override;
/** values in LineEdits */
QString name ();
QString server ();
diff --git a/kmuddy/dialogs/dlggrabkey.cpp b/kmuddy/dialogs/dlggrabkey.cpp
index 461bfaa..05048fb 100644
--- a/kmuddy/dialogs/dlggrabkey.cpp
+++ b/kmuddy/dialogs/dlggrabkey.cpp
@@ -24,19 +24,17 @@
#include <klocale.h>
#include <kvbox.h>
-dlgGrabKey::dlgGrabKey (QWidget *parent) : KDialog (parent)
+dlgGrabKey::dlgGrabKey (QWidget *parent) : QDialog (parent)
{
KMuddy::self()->setGrabDialog (this);
//initial dialog size
- setInitialSize (QSize (200, 80));
- setCaption (i18n ("Keygrabber"));
+ setCWindowTitle (i18n ("Keygrabber"));
setButtons (KDialog::Cancel);
setDefaultButton (KDialog::Cancel);
//create main dialog's widget
KVBox *vbox = new KVBox (this);
- setMainWidget (vbox);
new QLabel (i18n ("Press the desired shortcut..."), vbox);
}
@@ -45,6 +43,11 @@ dlgGrabKey::~dlgGrabKey ()
KMuddy::self()->setGrabDialog (0);
}
+QSize dlgGrabKey::sizeHint() const
+{
+ return QSize (200, 80);
+}
+
void dlgGrabKey::gotKey (int key, Qt::KeyboardModifiers state)
{
_key = key;
@@ -52,5 +55,3 @@ void dlgGrabKey::gotKey (int key, Qt::KeyboardModifiers state)
accept ();
}
-#include "dlggrabkey.moc"
-
diff --git a/kmuddy/dialogs/dlggrabkey.h b/kmuddy/dialogs/dlggrabkey.h
index bf6315e..c97d71e 100644
--- a/kmuddy/dialogs/dlggrabkey.h
+++ b/kmuddy/dialogs/dlggrabkey.h
@@ -18,7 +18,7 @@
#ifndef DLGGRABKEY_H
#define DLGGRABKEY_H
-#include <kdialog.h>
+#include <QDialog>
/**
This dialog is used to grab keys. It works in conjuction with event filter
@@ -33,11 +33,12 @@ KDE people say...). I don't use QAction here, so macro keys are \
not affected.
*@author Tomas Mecir
*/
-class dlgGrabKey : public KDialog {
+class dlgGrabKey : public QDialog {
Q_OBJECT
public:
dlgGrabKey (QWidget *parent=0);
~dlgGrabKey ();
+ virtual QSize sizeHint() const override;
/** key is here - sent by KMuddy::eventFilter */
void gotKey (int key, Qt::KeyboardModifiers state);
diff --git a/kmuddy/dialogs/dlgimportexportprofile.cpp \
b/kmuddy/dialogs/dlgimportexportprofile.cpp index 824a088..738eb27 100644
--- a/kmuddy/dialogs/dlgimportexportprofile.cpp
+++ b/kmuddy/dialogs/dlgimportexportprofile.cpp
@@ -17,49 +17,50 @@
#include "dlgimportexportprofile.h"
-#include <kfiledialog.h>
-#include <klineedit.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <kmessagebox.h>
-#include <kpushbutton.h>
-#include <qcombobox.h>
-#include <qlabel.h>
+
+#include <QComboBox>
+#include <QDialogButtonBox>
+#include <QFileDialog>
#include <QGridLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
dlgImportExportProfile::dlgImportExportProfile (bool isImport,
- QWidget *parent) : KDialog (parent)
+ QWidget *parent) : QDialog (parent)
{
import = isImport;
//initial dialog size
- setInitialSize (QSize (300, 150));
- setCaption (isImport ? i18n ("Import profile") : i18n ("Export profile"));
- setButtons (KDialog::Ok | KDialog::Cancel);
-
- //create main dialog's widget
- QWidget *page = new QWidget (this);
- QGridLayout *layout = new QGridLayout (page);
+ setWindowTitle (isImport ? i18n ("Import profile") : i18n ("Export profile"));
- setMainWidget (page);
+ QGridLayout *layout = new QGridLayout (this);
- QLabel *l1 = new QLabel (i18n ("&Profile name"), page);
+ QLabel *l1 = new QLabel (i18n ("&Profile name"), this);
if (isImport)
{
- edprofile = new KLineEdit (page);
+ edprofile = new QLineEdit (this);
l1->setBuddy (edprofile);
}
else
{
- cbprofile = new QComboBox (page);
+ cbprofile = new QComboBox (this);
//cProfiles p;
//cbprofile->addItems (p.getprofiles());
l1->setBuddy (cbprofile);
}
QLabel *l2 = new QLabel (isImport ? i18n ("&Import from") :
- i18n ("&Export to"), page);
- edfname = new KLineEdit (page);
+ i18n ("&Export to"), this);
+ edfname = new QLineEdit (this);
l2->setBuddy (edfname);
- KPushButton *button = new KPushButton (i18n ("Browse..."), page);
+ QPushButton *button = new QPushButton (i18n ("Browse..."), this);
+
+ QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | \
QDialogButtonBox::Cancel, this); + connect (buttons, &QDialogButtonBox::accepted, \
this, &QDialog::accept); + connect (buttons, &QDialogButtonBox::rejected, this, \
&QDialog::reject); +
layout->setSpacing (10);
layout->addWidget (l1, 0, 0);
layout->addWidget (l2, 1, 0);
@@ -69,6 +70,7 @@ dlgImportExportProfile::dlgImportExportProfile (bool isImport,
layout->addWidget (cbprofile, 0, 1);
layout->addWidget (edfname, 1, 1);
layout->addWidget (button, 1, 2);
+ layout->addWidget (buttons, 0, 3, 0, 2);
layout->setRowStretch (2, 10);
connect (button, SIGNAL (clicked()), this, SLOT (browse ()));
@@ -79,6 +81,11 @@ dlgImportExportProfile::~dlgImportExportProfile ()
}
+QSize dlgImportExportProfile::sizeHint() const
+{
+ return QSize (300, 150);
+}
+
void dlgImportExportProfile::doThings ()
{
KMessageBox::sorry (this, i18n ("I am sorry, but import and export is currently \
disabled. The functionality should be re-enabled before the final release.")); @@ \
-121,19 +128,15 @@ void dlgImportExportProfile::browse () {
if (import)
{
- QString n = KFileDialog::getOpenFileName (QString(),
- QString(), this, i18n ("Choose file with profile"));
+ QString n = QFileDialog::getOpenFileName (this, i18n ("Choose file with \
profile")); if (!(n.isEmpty()))
edfname->setText (n);
}
else
{
- QString n = KFileDialog::getSaveFileName (QString(),
- QString(), this, i18n ("Enter target file"));
+ QString n = QFileDialog::getSaveFileName (this, i18n ("Enter target file"));
if (!(n.isEmpty()))
edfname->setText (n);
}
}
-#include "dlgimportexportprofile.moc"
-
diff --git a/kmuddy/dialogs/dlgimportexportprofile.h \
b/kmuddy/dialogs/dlgimportexportprofile.h index dd9f598..6b5aa0f 100644
--- a/kmuddy/dialogs/dlgimportexportprofile.h
+++ b/kmuddy/dialogs/dlgimportexportprofile.h
@@ -18,9 +18,9 @@
#ifndef DLGIMPORTEXPORTPROFILE_H
#define DLGIMPORTEXPORTPROFILE_H
-#include <kdialog.h>
+#include <QDialog>
-class KLineEdit;
+class QLineEdit;
class QComboBox;
/**
@@ -28,18 +28,19 @@ Dialog where you choose what to import/export.
*@author Tomas Mecir
*/
-class dlgImportExportProfile : public KDialog {
+class dlgImportExportProfile : public QDialog {
Q_OBJECT
public:
dlgImportExportProfile (bool isImport, QWidget *parent=0);
~dlgImportExportProfile ();
void doThings ();
+ virtual QSize sizeHint() const override;
protected slots:
void browse ();
protected:
bool import;
- KLineEdit *edfname;
- KLineEdit *edprofile;
+ QLineEdit *edfname;
+ QLineEdit *edprofile;
QComboBox *cbprofile;
};
diff --git a/kmuddy/dialogs/dlgmudlist.cpp b/kmuddy/dialogs/dlgmudlist.cpp
index 640ce71..65ffdc9 100644
--- a/kmuddy/dialogs/dlgmudlist.cpp
+++ b/kmuddy/dialogs/dlgmudlist.cpp
@@ -44,7 +44,7 @@ struct dlgMudList::Private {
QSortFilterProxyModel *proxy;
};
-dlgMudList::dlgMudList (QWidget *parent) : KDialog (parent)
+dlgMudList::dlgMudList (QWidget *parent) : QDialog (parent)
{
d = new Private;
if (!lst)
@@ -52,16 +52,13 @@ dlgMudList::dlgMudList (QWidget *parent) : KDialog (parent)
lst = new cMUDList;
// initialize the dialog
- setInitialSize (QSize (750, 500));
- setCaption (i18n ("MUD Listing"));
+ setWindowTitle (i18n ("MUD Listing"));
setButtons (KDialog::Ok | KDialog::Cancel);
//create main dialog's widget
- QWidget *main = new QWidget (this);
- QVBoxLayout *mainLayout = new QVBoxLayout (main);
- setMainWidget (main);
+ QVBoxLayout *mainLayout = new QVBoxLayout (this);
- QSplitter *page = new QSplitter (main);
+ QSplitter *page = new QSplitter (this);
page->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
QWidget *left = new QWidget (page);
QGridLayout *layout = new QGridLayout (left);
@@ -75,7 +72,7 @@ dlgMudList::dlgMudList (QWidget *parent) : KDialog (parent)
d->details = new KTextBrowser (page);
page->addWidget (left);
page->addWidget (d->details);
- QLabel *source = new QLabel ("The list is provided courtesy of <a \
href=\"http://www.mudconnector.com/\">The MUD Connector</a>.<br/>If you are unsure \
which game to pick, you may also want to check out <a \
href=\"http://www.topmudsites.com\">www.topmudsites.com</a>.", main); + QLabel \
*source = new QLabel ("The list is provided courtesy of <a \
href=\"http://www.mudconnector.com/\">The MUD Connector</a>.<br/>If you are unsure \
which game to pick, you may also want to check out <a \
href=\"http://www.topmudsites.com\">www.topmudsites.com</a>.", this); \
source->setOpenExternalLinks (true); source->setWordWrap (true);
@@ -103,6 +100,11 @@ dlgMudList::~dlgMudList ()
delete d;
}
+QSize dlgMudList::sizeHint() const
+{
+ return QSize (750, 500);
+}
+
const cMUDEntry *dlgMudList::getEntry (QWidget *parent)
{
dlgMudList *dlg = new dlgMudList (parent);
@@ -150,4 +152,3 @@ const cMUDEntry *dlgMudList::selectedEntry ()
return lst->entry (d->proxy->mapToSource (idx).row());
}
-#include "dlgmudlist.moc"
diff --git a/kmuddy/dialogs/dlgmudlist.h b/kmuddy/dialogs/dlgmudlist.h
index 89f6edc..5117ba7 100644
--- a/kmuddy/dialogs/dlgmudlist.h
+++ b/kmuddy/dialogs/dlgmudlist.h
@@ -23,16 +23,17 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #ifndef DLGMUDLIST_H
#define DLGMUDLIST_H
-#include <kdialog.h>
+#include <QDialog>
#include <QModelIndex>
class cMUDEntry;
class cMUDList;
-class dlgMudList : public KDialog {
+class dlgMudList : public QDialog {
Q_OBJECT
public:
static const cMUDEntry *getEntry (QWidget *parent);
+ virtual QSize sizeHint() const override;
private slots:
void currentChanged (const QModelIndex &index);
private:
diff --git a/kmuddy/dialogs/dlgmultiline.cpp b/kmuddy/dialogs/dlgmultiline.cpp
index 2362d58..d1aa4aa 100644
--- a/kmuddy/dialogs/dlgmultiline.cpp
+++ b/kmuddy/dialogs/dlgmultiline.cpp
@@ -114,5 +114,3 @@ void dlgMultiLine::sendClicked ()
emit commands (cmds);
}
-#include "dlgmultiline.moc"
-
diff --git a/kmuddy/dialogs/dlgmultiline.h b/kmuddy/dialogs/dlgmultiline.h
index 0bd3a7d..e24ff20 100644
--- a/kmuddy/dialogs/dlgmultiline.h
+++ b/kmuddy/dialogs/dlgmultiline.h
@@ -34,6 +34,7 @@ class dlgMultiLine : public QDockWidget {
public:
dlgMultiLine (QWidget *parent = 0);
~dlgMultiLine ();
+ virtual QSize sizeHint() const override;
/** set font */
void setFont (const QFont &font);
signals:
diff --git a/kmuddy/dialogs/dlgmxpconsole.cpp b/kmuddy/dialogs/dlgmxpconsole.cpp
index 0bcf55c..1ae00f8 100644
--- a/kmuddy/dialogs/dlgmxpconsole.cpp
+++ b/kmuddy/dialogs/dlgmxpconsole.cpp
@@ -40,7 +40,6 @@ dlgMXPConsole::~dlgMXPConsole ()
void dlgMXPConsole::createDialog ()
{
- // setInitialSize (QSize (300, 200));
setWindowTitle (i18n ("MXP Console"));
viewer = new QTextEdit (this);
@@ -61,6 +60,10 @@ void dlgMXPConsole::addLine (const QString &line)
sb->setValue (sb->maximum ());
}
+QSize dlgObjects::sizeHint() const
+{
+ return QSize (300, 200);
+}
+
#endif //HAVE_MXP
-#include "dlgmxpconsole.moc"
diff --git a/kmuddy/dialogs/dlgmxpconsole.h b/kmuddy/dialogs/dlgmxpconsole.h
index bb95eaa..f0243a9 100644
--- a/kmuddy/dialogs/dlgmxpconsole.h
+++ b/kmuddy/dialogs/dlgmxpconsole.h
@@ -44,6 +44,7 @@ public:
dlgMXPConsole (QWidget *parent = 0);
/** destructor */
~dlgMXPConsole ();
+ virtual QSize sizeHint() const override;
/** add new line to the dialog */
void addLine (const QString &line);
protected:
diff --git a/kmuddy/dialogs/dlgobjects.cpp b/kmuddy/dialogs/dlgobjects.cpp
index b2ce8b8..1e588b1 100644
--- a/kmuddy/dialogs/dlgobjects.cpp
+++ b/kmuddy/dialogs/dlgobjects.cpp
@@ -55,13 +55,12 @@ struct dlgObjects::Private
};
dlgObjects::dlgObjects (QWidget *parent)
- : KDialog (parent), cActionBase ("dialog-objects", 0)
+ : QDialog (parent), cActionBase ("dialog-objects", 0)
{
d = new Private;
//initial dialog size
- setInitialSize (QSize (600, 400));
- setCaption (i18n ("Object Manager"));
+ setWindowTitle (i18n ("Object Manager"));
setButtons (KDialog::Close);
//create main dialog's widget
@@ -146,6 +145,11 @@ dlgObjects::~dlgObjects ()
delete d;
}
+QSize dlgObjects::sizeHint() const
+{
+ return QSize (600, 400);
+}
+
void dlgObjects::eventNothingHandler (QString event, int session)
{
if (event == "connected") {
@@ -233,4 +237,3 @@ void dlgObjects::activeObjectChanged (cListObject *obj)
kDebug () << "Switched active object to " << obj->name() << "." << endl;
}
-#include "dlgobjects.moc"
diff --git a/kmuddy/dialogs/dlgobjects.h b/kmuddy/dialogs/dlgobjects.h
index d71a086..fa397ae 100644
--- a/kmuddy/dialogs/dlgobjects.h
+++ b/kmuddy/dialogs/dlgobjects.h
@@ -23,16 +23,17 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #ifndef DLGOBJECTS_H
#define DLGOBJECTS_H
-#include <kdialog.h>
+#include <QDialog>
#include "cactionbase.h"
class cListObject;
-class dlgObjects: public KDialog, public cActionBase {
+class dlgObjects: public QDialog, public cActionBase {
Q_OBJECT
public:
dlgObjects (QWidget *parent = 0);
~dlgObjects ();
+ virtual QSize sizeHint() const override;
private slots:
void listChanged (int index);
diff --git a/kmuddy/dialogs/dlgoutputwindow.cpp b/kmuddy/dialogs/dlgoutputwindow.cpp
index 599ee88..ffde130 100644
--- a/kmuddy/dialogs/dlgoutputwindow.cpp
+++ b/kmuddy/dialogs/dlgoutputwindow.cpp
@@ -31,21 +31,17 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include <netwm_def.h>
#include <QVBoxLayout>
-dlgOutputWindow::dlgOutputWindow (QWidget *parent) : KDialog(parent)
+dlgOutputWindow::dlgOutputWindow (QWidget *parent) : QDialog(parent)
{
//initial size
- setInitialSize (QSize (250, 300));
- setCaption (i18n ("Output window"));
- setButtons (0);
+ setWindowTitle (i18n ("Output window"));
//main widget
- QWidget *page = new QWidget (this);
- QVBoxLayout *layout = new QVBoxLayout (page);
+ QVBoxLayout *layout = new QVBoxLayout (this);
- setMainWidget (page);
setFocusPolicy (Qt::StrongFocus);
- owindow = new cConsole(true, page);
+ owindow = new cConsole(this);
//our window shall also have a status bar
owindow->setVScrollBarMode (Q3ScrollView::AlwaysOn);
@@ -65,6 +61,11 @@ dlgOutputWindow::~dlgOutputWindow()
{
}
+QSize dlgOutputWindow::sizeHint() const
+{
+ return QSize (250, 300);
+}
+
void dlgOutputWindow::setSession (int _sess)
{
sess = _sess;
@@ -81,7 +82,7 @@ void dlgOutputWindow::addLine (cTextChunk *chunk)
void dlgOutputWindow::setOutputWindowName(const QString &name)
{
if(!name.isEmpty())
- this->setCaption(name);
+ this->setWindowTitle(name);
}
void dlgOutputWindow::setFont(QFont font)
@@ -89,5 +90,3 @@ void dlgOutputWindow::setFont(QFont font)
owindow->setFont(font);
}
-#include "dlgoutputwindow.moc"
-
diff --git a/kmuddy/dialogs/dlgoutputwindow.h b/kmuddy/dialogs/dlgoutputwindow.h
index b695f4f..f85cc20 100644
--- a/kmuddy/dialogs/dlgoutputwindow.h
+++ b/kmuddy/dialogs/dlgoutputwindow.h
@@ -24,7 +24,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #define DLGOUTPUTWINDOW_H
#include <qfont.h>
-#include <kdialog.h>
+#include <QDialog>
#include <kwindowsystem.h>
class cConsole;
@@ -35,13 +35,14 @@ One output window.
@author Vladimir Lazarenko
*/
-class dlgOutputWindow : public KDialog
+class dlgOutputWindow : public QDialog
{
Q_OBJECT
public:
dlgOutputWindow (QWidget *parent = 0);
~dlgOutputWindow();
+ virtual QSize sizeHint() const override;
void addLine (cTextChunk *chunk);
void setOutputWindowName(const QString &name);
void setFont(QFont font);
diff --git a/kmuddy/dialogs/dlgprofilesettings.cpp \
b/kmuddy/dialogs/dlgprofilesettings.cpp index a547ab2..850a27f 100644
--- a/kmuddy/dialogs/dlgprofilesettings.cpp
+++ b/kmuddy/dialogs/dlgprofilesettings.cpp
@@ -39,9 +39,8 @@ dlgProfileSettings::dlgProfileSettings (QWidget *parent) : \
KPageDialog (parent) cDialogList::self()->addDialog ("profile-prefs", this);
//initial dialog size
- setInitialSize (QSize (450, 350));
- setCaption (i18n ("MUD preferences"));
- setButtons (KDialog::Ok | KDialog::Cancel | KDialog::Apply);
+ setWindowTitle (i18n ("MUD preferences"));
+ setStandardButtons (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | \
QDialogButtonBox::Apply); setFaceType (KPageDialog::List);
//prepare dialog pages
@@ -252,6 +251,11 @@ dlgProfileSettings::~dlgProfileSettings ()
}
+QSize dlgProfileSettings::sizeHint() const
+{
+ return QSize (450, 350);
+}
+
bool dlgProfileSettings::useAnsi ()
{
return useansi->isChecked ();
@@ -471,5 +475,3 @@ QString dlgProfileSettings::variablePrefix ()
#endif //HAVE_MXP
-#include "dlgprofilesettings.moc"
-
diff --git a/kmuddy/dialogs/dlgprofilesettings.h \
b/kmuddy/dialogs/dlgprofilesettings.h index 6281bec..a366aa2 100644
--- a/kmuddy/dialogs/dlgprofilesettings.h
+++ b/kmuddy/dialogs/dlgprofilesettings.h
@@ -40,6 +40,7 @@ public:
dlgProfileSettings (QWidget *parent=0);
~dlgProfileSettings ();
+ virtual QSize sizeHint() const override;
bool useAnsi ();
void setUseAnsi (bool val);
bool limitRepeater ();
diff --git a/kmuddy/dialogs/dlgquickconnect.cpp b/kmuddy/dialogs/dlgquickconnect.cpp
index bdded86..da3338a 100644
--- a/kmuddy/dialogs/dlgquickconnect.cpp
+++ b/kmuddy/dialogs/dlgquickconnect.cpp
@@ -28,11 +28,10 @@
#include <klineedit.h>
#include <krestrictedline.h>
-dlgQuickConnect::dlgQuickConnect(QWidget *parent) : KDialog (parent)
+dlgQuickConnect::dlgQuickConnect(QWidget *parent) : QDialog (parent)
{
//initial dialog size
- setInitialSize (QSize (300, 120));
- setCaption (i18n ("Quick Connect"));
+ setWindowTitle (i18n ("Quick Connect"));
setButtons (KDialog::Ok | KDialog::Cancel);
//create main dialog's widget
@@ -77,6 +76,11 @@ dlgQuickConnect::~dlgQuickConnect()
}
+QSize dlgQuickConnect::sizeHint() const
+{
+ return QSize (300, 120);
+}
+
QString dlgQuickConnect::host ()
{
return ed1->text();
@@ -87,5 +91,3 @@ int dlgQuickConnect::port ()
return ed2->text().toInt ();
}
-#include "dlgquickconnect.moc"
-
diff --git a/kmuddy/dialogs/dlgquickconnect.h b/kmuddy/dialogs/dlgquickconnect.h
index 609b5a3..cb788e2 100644
--- a/kmuddy/dialogs/dlgquickconnect.h
+++ b/kmuddy/dialogs/dlgquickconnect.h
@@ -19,7 +19,7 @@
#ifndef DLGQUICKCONNECT_H
#define DLGQUICKCONNECT_H
-#include <kdialog.h>
+#include <QDialog>
class KLineEdit;
class KRestrictedLine;
@@ -29,12 +29,13 @@ QuickConnect dialog - handled by cConnection.
*@author Tomas Mecir
*/
-class dlgQuickConnect : public KDialog {
+class dlgQuickConnect : public QDialog {
Q_OBJECT
public:
dlgQuickConnect (QWidget *parent=0);
~dlgQuickConnect ();
+ virtual QSize sizeHint() const override;
/** values in LineEdits */
QString host ();
int port ();
diff --git a/kmuddy/dialogs/dlgstatistics.cpp b/kmuddy/dialogs/dlgstatistics.cpp
index 9f41a7d..04a8067 100644
--- a/kmuddy/dialogs/dlgstatistics.cpp
+++ b/kmuddy/dialogs/dlgstatistics.cpp
@@ -141,5 +141,3 @@ void dlgStatistics::update ()
view->addTopLevelItems (items);
}
-#include "dlgstatistics.moc"
-
diff --git a/kmuddy/dialogs/dlgtranscript.cpp b/kmuddy/dialogs/dlgtranscript.cpp
index 5d5381f..bddbf40 100644
--- a/kmuddy/dialogs/dlgtranscript.cpp
+++ b/kmuddy/dialogs/dlgtranscript.cpp
@@ -34,8 +34,7 @@ dlgTranscript::dlgTranscript (QWidget *parent) :
KPageDialog (parent)
{
//initial dialog size
- setInitialSize (QSize (400, 200));
- setCaption (i18n ("Session Transcript"));
+ setWindowTitle (i18n ("Session Transcript"));
setFaceType( KPageDialog::Tabbed );
setButtons (KDialog::Ok | KDialog::Cancel | KDialog::Apply);
@@ -172,6 +171,11 @@ dlgTranscript::~dlgTranscript ()
}
+QSize dlgTranscript::sizeHint() const
+{
+ return QSize (400, 200);
+}
+
void dlgTranscript::updateDialog (bool how)
{
overwrite->setEnabled (how);
@@ -296,5 +300,3 @@ char dlgTranscript::advTranscriptType ()
return advttype->currentIndex() + 1;
}
-#include "dlgtranscript.moc"
-
diff --git a/kmuddy/dialogs/dlgtranscript.h b/kmuddy/dialogs/dlgtranscript.h
index 0f2ef7e..823c47d 100644
--- a/kmuddy/dialogs/dlgtranscript.h
+++ b/kmuddy/dialogs/dlgtranscript.h
@@ -39,6 +39,7 @@ public:
dlgTranscript (QWidget *parent=0);
~dlgTranscript ();
+ virtual QSize sizeHint() const override;
QString getFName ();
QString getAFName ();
void setFName (const QString &filename);
diff --git a/kmuddy/dialogs/dlgwindows.cpp b/kmuddy/dialogs/dlgwindows.cpp
index bc8c255..a9dc7a2 100644
--- a/kmuddy/dialogs/dlgwindows.cpp
+++ b/kmuddy/dialogs/dlgwindows.cpp
@@ -33,7 +33,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include <QListWidget>
#include <QVBoxLayout>
-dlgWindows::dlgWindows(cWindowList *wlist, QWidget *parent) : KDialog(parent)
+dlgWindows::dlgWindows(cWindowList *wlist, QWidget *parent) : QDialog(parent)
{
wl = wlist->windowList();
winlist = wlist;
@@ -49,8 +49,7 @@ dlgWindows::~dlgWindows()
void dlgWindows::createDialog()
{
//initial dialog size
- setInitialSize (QSize (500, 400));
- setCaption (i18n("Output Windows"));
+ setWindowTitle (i18n("Output Windows"));
setButtons (KDialog::Ok);
//create main dialog's widget
@@ -97,6 +96,11 @@ void dlgWindows::createDialog()
}
+QSize dlgWindows::sizeHint() const
+{
+ return QSize (500, 400);
+}
+
void dlgWindows::wshow()
{
if (!box->count()) return;
@@ -158,5 +162,3 @@ void dlgWindows::updateMe ()
box->setCurrentRow (0);
}
-
-#include "dlgwindows.moc"
diff --git a/kmuddy/dialogs/dlgwindows.h b/kmuddy/dialogs/dlgwindows.h
index 7bae475..6d3096c 100644
--- a/kmuddy/dialogs/dlgwindows.h
+++ b/kmuddy/dialogs/dlgwindows.h
@@ -23,10 +23,9 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #ifndef DLGWINDOWS_H
#define DLGWINDOWS_H
+#include <QDialog>
#include <QLabel>
-#include <kdialog.h>
-class QLabel;
class QListWidget;
class KPushButton;
class QStringList;
@@ -36,13 +35,14 @@ class cWindowList;
/**
@author Vladimir Lazarenko
*/
-class dlgWindows : public KDialog
+class dlgWindows : public QDialog
{
Q_OBJECT
public:
dlgWindows(cWindowList *wlist, QWidget *parent = 0);
-
~dlgWindows();
+
+ virtual QSize sizeHint() const override;
protected slots:
void wshow();
diff --git a/kmuddy/kmuddy.cpp b/kmuddy/kmuddy.cpp
index 9e94668..1a91e3a 100644
--- a/kmuddy/kmuddy.cpp
+++ b/kmuddy/kmuddy.cpp
@@ -1281,13 +1281,13 @@ void KMuddy::pageDown ()
void KMuddy::aconUp ()
{
cOutput *output = dynamic_cast<cOutput *>(am->object ("output", activeSession()));
- output->console()->aconUp();
+ output->aconUp();
}
void KMuddy::aconDown ()
{
cOutput *output = dynamic_cast<cOutput *>(am->object ("output", activeSession()));
- output->console()->aconDown();
+ output->aconDown();
}
bool KMuddy::eventFilter (QObject *o, QEvent *e)
diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
index 9d44bc5..052f6b4 100644
--- a/libs/CMakeLists.txt
+++ b/libs/CMakeLists.txt
@@ -56,7 +56,7 @@ set(kmuddycore_LIB_SRCS
add_library(kmuddycore SHARED ${kmuddycore_LIB_SRCS})
# TODO: get rid of the support libs
-target_link_libraries(kmuddycore KF5::Service KF5::KDELibs4Support Qt5::Script)
+target_link_libraries(kmuddycore KF5::KCMUtils KF5::I18n KF5::Service \
KF5::KDELibs4Support Qt5::Script Qt5::Multimedia)
set_target_properties(kmuddycore PROPERTIES VERSION 1.0.0 SOVERSION 1 )
install(TARGETS kmuddycore DESTINATION ${LIB_INSTALL_DIR} )
diff --git a/libs/arith-exp.cpp b/libs/arith-exp.cpp
index 07f5d16..eb43fc8 100644
--- a/libs/arith-exp.cpp
+++ b/libs/arith-exp.cpp
@@ -64,7 +64,7 @@ bool arith_exp::compile (const QString &expression)
{
clear_compiled();
- return ::compile(expression.toLocal8Bit(),
+ return ::compile(expression.toLocal8Bit().data(),
&compiled_code);
} // arith_exp::compile
diff --git a/libs/caliaseditor.cpp b/libs/caliaseditor.cpp
index 472cca4..082fcfc 100644
--- a/libs/caliaseditor.cpp
+++ b/libs/caliaseditor.cpp
@@ -37,8 +37,8 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include <QTreeWidget>
#include <QVBoxLayout>
+#include <KLocalizedString>
#include <klineedit.h>
-#include <klocale.h>
#include <ktextedit.h>
#include <KServiceTypeTrader>
@@ -394,4 +394,3 @@ void cAliasEditor::getDataFromGUI (cListObjectData *data)
data->boolValues["global"] = d->check5->isChecked();
}
-#include "caliaseditor.moc"
diff --git a/libs/cansiparser.cpp b/libs/cansiparser.cpp
index 5ab35d7..dec46e7 100644
--- a/libs/cansiparser.cpp
+++ b/libs/cansiparser.cpp
@@ -355,6 +355,7 @@ void cANSIParser::changeColor (int color)
break;
case 25: //BLINK OFF
blinkactive = false;
+ break;
//26 is proportional spacing - NOT SUPPORTED
case 27: //POSITIVE IMAGE
negactive = false;
@@ -404,5 +405,3 @@ void cANSIParser::changeColor (int color)
}
}
-#include "cansiparser.moc"
-
diff --git a/libs/cansiparser.h b/libs/cansiparser.h
index 10ae46e..861233a 100644
--- a/libs/cansiparser.h
+++ b/libs/cansiparser.h
@@ -63,7 +63,7 @@ public:
void setUseAnsi (bool val) { useansi = val; };
- virtual void eventNothingHandler (QString event, int session);
+ virtual void eventNothingHandler (QString event, int session) override;
signals:
void fgColor (QColor color);
diff --git a/libs/ccmdparser.cpp b/libs/ccmdparser.cpp
index 463a282..3d3fc32 100644
--- a/libs/ccmdparser.cpp
+++ b/libs/ccmdparser.cpp
@@ -29,7 +29,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include "clistmanager.h"
#include "cprofilesettings.h"
-#include <klocale.h>
+#include <KLocalizedString>
cCmdParser::cCmdParser (int sess)
: cActionBase ("cmdparser", sess)
diff --git a/libs/ccmdparser.h b/libs/ccmdparser.h
index 4b9bb6e..aaf0bf9 100644
--- a/libs/ccmdparser.h
+++ b/libs/ccmdparser.h
@@ -69,7 +69,7 @@ class KMUDDY_EXPORT cCmdParser : public cActionBase
/** remove the raw flag from the command */
QString fixRaw (const QString &command);
protected:
- virtual void eventNothingHandler (QString event, int session);
+ virtual void eventNothingHandler (QString event, int session) override;
/** split text into commands, using command separators and \n */
QStringList splitIntoCommands (const QString &text);
diff --git a/libs/ccmdprocessor.cpp b/libs/ccmdprocessor.cpp
index 8f254c7..d0cbd3d 100644
--- a/libs/ccmdprocessor.cpp
+++ b/libs/ccmdprocessor.cpp
@@ -23,7 +23,7 @@
#include "cmacromanager.h"
#include "cvariablelist.h"
-#include <klocale.h>
+#include <KLocalizedString>
#include <map>
@@ -247,8 +247,8 @@ int cCmdProcessor::isFocusCommand (const QString &command)
{
int pos;
if ((focusstr.length() > 0) && (command.startsWith(focusstr))) {
- command.trimmed(); //removes leading/trailing spaces
- if ((pos = command.indexOf(focusstr,focusstr.length())) == -1)
+ QString cmd = command.trimmed(); //removes leading/trailing spaces
+ if ((pos = cmd.indexOf(focusstr, focusstr.length())) == -1)
return -1; //return false if a second focustr can't be found
return pos;
}
diff --git a/libs/ccmdprocessor.h b/libs/ccmdprocessor.h
index 258f036..78369b2 100644
--- a/libs/ccmdprocessor.h
+++ b/libs/ccmdprocessor.h
@@ -52,7 +52,7 @@ public:
cValue eval (const QString &exp, cCmdQueue *queue, bool &ok);
protected:
- virtual void eventNothingHandler (QString event, int session);
+ virtual void eventNothingHandler (QString event, int session) override;
/** Looks to see if this is a tab/window command call. If it is, the command
is split into :window:mytext */
diff --git a/libs/ccmdqueues.cpp b/libs/ccmdqueues.cpp
index c8b6b02..7f44746 100644
--- a/libs/ccmdqueues.cpp
+++ b/libs/ccmdqueues.cpp
@@ -141,4 +141,3 @@ void cCmdQueues::processQueue (cCmdQueue *queue)
}
}
-#include "ccmdqueues.moc"
diff --git a/libs/ccmdqueues.h b/libs/ccmdqueues.h
index d0321e0..0a31839 100644
--- a/libs/ccmdqueues.h
+++ b/libs/ccmdqueues.h
@@ -56,8 +56,8 @@ class KMUDDY_EXPORT cCmdQueues : public QObject, public cActionBase
protected slots:
void timeout ();
protected:
- virtual void eventChunkHandler (QString event, int session, cTextChunk *chunk);
- virtual void eventStringHandler (QString event, int session, QString &par1, const \
QString &par2); + virtual void eventChunkHandler (QString event, int session, \
cTextChunk *chunk) override; + virtual void eventStringHandler (QString event, int \
session, QString &par1, const QString &par2) override;
/** react on a line */
void gotLine (const QString &line);
diff --git a/libs/cconsole.cpp b/libs/cconsole.cpp
index 81421ef..5c0136a 100644
--- a/libs/cconsole.cpp
+++ b/libs/cconsole.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- cconsole.cpp - main displaying widget
+ cconsole.cpp - main displaying widget v2
This file is a part of KMuddy distribution.
-------------------
- begin : So Jun 22 2002
- copyright : (C) 2002-2007 by Tomas Mecir
- email : kmuddy@kmuddy.com
+ begin : So Dec 21 2017
+ copyright : (C) 2002-2017 by Tomas Mecir
+ email : mecirt@gmail.com
***************************************************************************/
/***************************************************************************
@@ -16,157 +16,103 @@
* *
***************************************************************************/
-#define CCONSOLE_CPP
-
#include "cconsole.h"
#include "cactionmanager.h"
-#include "cansiparser.h"
#include "ctextchunk.h"
#include <QAction>
-#include <QClipboard>
-#include <QEvent>
-#include <QFontMetrics>
-#include <QMouseEvent>
-#include <QPainter>
-#include <QPixmap>
-#include <QTimer>
-#include <QToolTip>
-#include <kactioncollection.h>
-#include <kapplication.h>
-#include <kglobalsettings.h>
-#include <klocale.h>
-#include <kmenu.h>
-#include <ktoolinvocation.h>
-
-#include <ctype.h>
-
-class cANSIParser;
-
-#define BLINK_INTERVAL 1000
-
-cHistoryBuffer::cHistoryBuffer (int size)
-{
- _size = size;
- _items = 0;
- curidx = 0;
- typedef cTextChunk *ucTextChunk;
- buffer = new ucTextChunk[_size];
- for (int i = 0; i < _size; i++)
- buffer[i] = 0;
-}
-
-cHistoryBuffer::~cHistoryBuffer ()
-{
- for (int i = 0; i < _size; i++)
- {
- delete buffer[i];
- buffer[i] = 0;
- }
- delete[] buffer;
-}
-
-void cHistoryBuffer::add (cTextChunk *chunk)
-{
- if (_items < _size)
- _items++;
- else
- {
- delete buffer[curidx];
- buffer[curidx] = 0;
- }
- buffer[curidx] = chunk;
- curidx++;
- if (curidx >= _size) curidx = 0;
-}
-
-cTextChunk * cHistoryBuffer::operator[] (int idx)
-{
- return (_items < _size) ? buffer[idx] : buffer[(curidx + idx) % _size];
-}
-
-void cHistoryBuffer::flush ()
-{
- for (int i = 0; i < _size; i++)
- {
- delete buffer[i];
- buffer[i] = 0;
- }
- _items = 0;
- curidx = 0;
-}
-
-
-int cConsole::initHistory = 1000;
-
-inline void swap (int &a, int &b)
-{
- int tmp = a;
- a = b;
- b = tmp;
-}
-
-cConsole::cConsole (bool auxiliary, QWidget *parent, const char *name) :
- QTableView (parent, name)
-{
-// setAttribute (Qt::WA_StaticContents);
-// setAttribute (Qt::WA_NoBackground);
-
- sess = -1;
- aux = auxiliary;
- aconvisible = false;
-
- bgcolor = Qt::black;
- usedrows = 0;
- currow = -1;
- currowpos = -1;
- wrappos = 0;
-
- currows = curcols = 0;
- charCount = charWidth = 0;
-
- if (!aux)
- historySize = initHistory; //set history size; won't be modified if
- //user changes that setting in global prefs, that'll only affect new
- //connections
- else
- historySize = 100; //aux. console does not need that big history
- QTableView::setNumCols (1);
+#include <QFontDatabase>
+#include <QGraphicsTextItem>
+#include <QTextCursor>
+#include <QTextDocument>
+
+#include <KActionCollection>
+
+/**
+Class cHistoryBuffer - holds the whole buffer, rotates it when needed and provides \
access to it. +Inspired by a similar class from Alex Bache.
+*/
+
+class KMUDDY_EXPORT cHistoryBuffer {
+ public:
+ /** create the cyclic buffer of a given size */
+ cHistoryBuffer (int size);
+ /** destructor */
+ ~cHistoryBuffer ();
+ /** current number of items in the buffer */
+ int items () { return _items; };
+ /** current size of the buffer */
+ int size () { return _size; };
+ /** add a new line to the buffer */
+ void add (cTextChunk *chunk);
+ /** Returns one line in the buffer.
+ Returns cTextChunk*, not cTextChunk*& - so that we can modify the chunk contents, \
but we + cannot assign another chunk to any given position,*/
+ cTextChunk * operator[] (int idx);
+ /** flush the buffer */
+ void flush ();
+ protected:
+ int _size, _items;
+ /** position in the cyclic buffer, where the NEXT added item will go */
+ int curidx;
+ /** the actual buffer */
+ cTextChunk **buffer;
+};
+
+class cConsole::Private {
+ QGraphicsScene scene;
+ QGraphicsTextItem *mainText, *scrollText;
+ QTextDocument *text;
+
+ QColor bgcolor;
+ QFont font;
+ int sess;
+ int charWidth, charHeight;
+ bool wantNewLine;
+
+ friend class cConsole;
+};
+
+
+
+
+cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) {
+ d = new Private;
+ d->sess = -1;
+ d->charWidth = 12;
+ d->charHeight = 12;
+ d->wantNewLine = false;
+
+ d->text = new QTextDocument;
+ QString stylesheet = "body { color: " + QColor (Qt::lightGray).name() + "; } ";
+ d->text->setDefaultStyleSheet (stylesheet);
+ QTextOption opt;
+ opt.setWrapMode (QTextOption::WrapAtWordBoundaryOrAnywhere);
+ d->text->setDefaultTextOption (opt);
+
+ d->mainText = new QGraphicsTextItem;
+ d->mainText->setDocument (d->text);
+ d->mainText->setFiltersChildEvents (true);
+
+ d->scrollText = new QGraphicsTextItem;
+ d->scrollText->setDocument (d->text);
+ d->scrollText->setParentItem (d->mainText);
+ d->scrollText->setFocusProxy (d->mainText);
+ d->scrollText->setVisible (false);
+
+ setScene (&d->scene);
+ d->scene.addItem (d->mainText);
+ d->scene.addItem (d->scrollText);
+ d->scene.setFocusItem (d->mainText);
- wordWrapping = true;
- indentValue = 0;
-
- //prepare the cache
- for (int i = 0; i < MAXCACHE; i++)
- {
- cacheEntry[i] = 0;
- cacheBlinkOn[i] = 0;
- cacheBlinkOff[i] = 0;
- }
-
- //blinking
- blinkPhase = true;
- blinking = false;
- blinkTimer = 0;
-
- buffer = new cHistoryBuffer (historySize);
-
- selected = false;
- canselect = false;
-
- repaintCount = 10;
- newlineCounter = 0;
-
//background color
- QColor defbkcolor = Qt::black;
+ d->bgcolor = Qt::black;
QPalette pal = palette();
- pal.setColor (backgroundRole(), defbkcolor);
- pal.setColor (QPalette::Base, defbkcolor);
+ pal.setColor (backgroundRole(), d->bgcolor);
+ pal.setColor (QPalette::Base, d->bgcolor);
setPalette (pal);
- viewport()->setPalette (pal);
setBackgroundRole (QPalette::Base);
- viewport()->setBackgroundRole (QPalette::Base);
//size policy
QSizePolicy qsp (QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -190,1266 +136,175 @@ cConsole::cConsole (bool auxiliary, QWidget *parent, const \
char *name) : addAction (sep2);
if (fullscreenmode) addAction (fullscreenmode);
- //create our auxiliary console if needed
- if (!aux)
- {
- aconsole = new cConsole (true, this);
- aconsole->hide ();
- aconvisible = false;
- aconsize = 25; //aconsole covers 25% by default
-
- //connect some auxiliary console's signals to ours, so that links work correctly
- connect (aconsole, SIGNAL (sendCommand (const QString &)), this,
- SIGNAL (sendCommand (const QString &)));
- connect (aconsole, SIGNAL (promptCommand (const QString &)), this,
- SIGNAL (promptCommand (const QString &)));
- }
- else
- aconsole = 0;
-
- //initialize menu-link variables
- menuChunk = 0;
- linkMenu = 0;
-
- //set default system fixed font
- setFont (KGlobalSettings::fixedFont ()); //default system fixed font
-
- //set the I-beam cursor
- viewport()->setCursor (Qt::IBeamCursor);
- ishandcursor = false;
-
- //we want to receive mouse-move messages all the time
- setMouseTracking (true);
- viewport()->setMouseTracking (true);
-
- //fix output
- fixupOutput ();
-}
-
-cConsole::~cConsole()
-{
- if (blinkTimer != 0)
- {
- blinkTimer->stop();
- delete blinkTimer;
- }
- emptyCache ();
- if (!aux)
- delete aconsole;
- delete buffer;
-}
-
-void cConsole::setSession (int s)
-{
- sess = s;
- if (!aux)
- aconsole->setSession (s);
-}
-
-cConsole *cConsole::auxConsole ()
-{
- if (aux)
- return 0;
- else
- return aconsole;
-}
-
-void cConsole::setFont (QFont f)
-{
- myfont = f;
- QFontMetrics fm (myfont);
- descent = fm.descent ();
- charWidth = fm.width ("m");
- setCellHeight (fm.height () + 2);
+ setFont (QFontDatabase::systemFont (QFontDatabase::FixedFont)); //default system \
fixed font + setCursor (Qt::IBeamCursor);
- ///fix output window
- fixupOutput ();
-
- //and repaint everything
- repaintContents (false);
- if (!aux)
- aconsole->setFont (f);
+ fixupOutput();
}
-void cConsole::setDefaultBkColor (QColor color)
-{
- bgcolor = color;
- QPalette pal = palette();
- pal.setColor (backgroundRole(), bgcolor);
- pal.setColor (QPalette::Base, bgcolor);
- setPalette (pal);
- viewport()->setPalette (pal);
- emptyCache ();
- repaintContents (false);
- if (!aux)
- aconsole->setDefaultBkColor (color);
+cConsole::~cConsole() {
+ delete d->scrollText;
+ delete d->mainText;
+ delete d->text;
+ // TODO
+ delete d;
}
-void cConsole::setWordWrapping (bool val)
-{
- wordWrapping = val;
- if (!aux)
- aconsole->setWordWrapping (val);
+void cConsole::setSession (int s) {
+ d->sess = s;
}
-void cConsole::setIndentation (int val)
-{
- //indentation must not exceed 10 characters
- if ((val >= 0) && (val <= 10))
- indentValue = val;
- if (!aux)
- aconsole->setIndentation (val);
-}
-
-void cConsole::setWrapPos (int wp)
-{
- wrappos = wp;
- if (!aux)
- aconsole->setWrapPos (wp);
-}
-
-void cConsole::setEnableBlinking (bool value)
-{
- //look if this changes blinking status
- if (blinking == value)
- return;
-
- //if so, update blinking timer status
- blinking = value;
- if (blinking)
- {
- if (blinkTimer == 0)
- {
- blinkTimer = new QTimer (this);
- connect (blinkTimer, SIGNAL (timeout()), this, SLOT (blinkTimerTimeout ()));
- }
- //blinking will occur once per second
- blinkTimer->start (BLINK_INTERVAL);
- //we start with characters displayed
- blinkPhase = true;
- }
- else
- {
- if (blinkTimer != 0)
- {
- blinkPhase = true;
- blinkTimer->stop ();
- //if status goes from enabled to disabled, we may need to repaint - do it!
- updateContents ();
- }
- }
-
- if (!aux)
- aconsole->setEnableBlinking (value);
-}
-
-QStringList cConsole::words (QString prefix, int minLength)
-{
- QStringList lst;
- int row = usedrows - 100, nHits=0;
- if (row < 0) row = 0;
-
- for (; row < usedrows; ++row)
- {
- cTextChunk *chunk = (*buffer)[row];
- lst += chunk->words (minLength);
- }
- // no sorting - we want to offer words in order of appearance
- // lst.sort ();
-
- //get rid of words that don't meet our requirements
- QStringList::iterator it = lst.begin();
- while (it != lst.end()) {
- // by Magnus Lundborg and me:
- if ((*it).startsWith (prefix, Qt::CaseInsensitive)) {
- int prevIndex = lst.indexOf(*it);
- /* If there is a previous occurence, but it is the last of the "hits" do
- not remove that one just remove this one instead. */
- if (prevIndex == nHits-1)
- {
- it=lst.erase (it);
- continue;
- }
- if (prevIndex != -1 && prevIndex != nHits-1)
- {
- QStringList::iterator prev = lst.begin() + prevIndex;
- if (prev != it)
- {
- // there is a previous word - delete it
- lst.erase (prev);
- --nHits;
- }
- }
- // move on
- ++it;
- ++nHits;
- }
- else
- // the word does not match - delete it
- it = lst.erase (it);
- }
- return lst;
-}
-
-// TODO: looks like this is currently unused ...
-void cConsole::clear ()
-{
- emptyCache ();
-
- buffer->flush ();
-
- int oldHistorySize = historySize;
-
- //update history size...
- if (!aux)
- historySize = initHistory;
- else
- historySize = 100; //aux. console does not need that big history
-
- aconsize = 25; //aconsole covers 25% by default
-
- usedrows = 0;
- currow = -1;
- currowpos = -1;
-
- setNumRows (0);
-
- if (oldHistorySize != historySize)
- {
- //reallocate memory
- delete buffer;
- buffer = new cHistoryBuffer(historySize);
- }
-
- repaintContents ();
- if (!aux)
- aconsole->clear ();
-
- //fix output
- fixupOutput ();
-
- //this processEvents() MUST be here! - otherwise aconsole gets shown on
- //second+ connection... (problem with scrollbar's maxvalue)
- (KApplication::kApplication ())->processEvents ();
- if (!aux)
- sliderChanged (0); //this one is needed as well
-}
-
-void cConsole::addLine (cTextChunk *chunk)
-{
- addNewText (chunk, true);
-}
-
-void cConsole::addText (cTextChunk *chunk)
-{
- addNewText (chunk, false);
-}
-
-void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
-{
- if (!chunk)
- {
- if (endTheLine)
- endLine ();
- return;
- }
-
- //wrap position
- int wp = wrappos;
- if ((wrappos < 20) || (wrappos > charCount))
- wp = charCount;
-
- //disable repainting
- setUpdatesEnabled (false);
-
- pendingLineMove = 0;
-
- //create a duplicate, as we cannot delete the original chunk
- cTextChunk *storedChunk = chunk;
- chunk = chunk->duplicate ();
-
- //first of all, if we're writing the very first string
- if (currow == -1)
- endLine (); //prepare first line
-
- //we'll go line after line (visible line, not received line), trying to
- //find wrap-position, then we copy that part of the string to another
- //string and display it
- cTextChunk *nextchunk = 0;
- do {
- //delete current line from the redraw cache
- for (int j = MAXCACHE - 1; j >= 0; j--)
- if ((cacheBlinkOn[j] != 0) && (cacheEntry[j] == currow))
- deleteCacheEntry (j);
-
- nextchunk = chunk->splitLine (wp - currowpos, wordWrapping, indentValue, true);
- (*buffer)[currow]->append (chunk);
- currowpos = (*buffer)[currow]->startAttr().startpos + \
(*buffer)[currow]->length();
-
- if (nextchunk == 0) //last part of chunk
- {
- if (endTheLine) //we should end the line -> do it!
- endLine ();
- else
- if (currowpos >= wp - 1)
- //otherwise end the line if we've reached its end
- endLine ();
- }
- else
- endLine (); //goin' to new line
- chunk = nextchunk;
- } while (nextchunk);
-
- //increase number of rows if needed; it's not in endLine for speed's sake
- if (numRows() < currow + 1)
- setNumRows (currow + 1);
-
- //ensure cell visibility if needed; it's not in endLine for speed's sake
- if (aux || (!aconvisible))
- ensureCellVisible (currow, 0);
- else
- if ((currow == historySize - 1) && pendingLineMove)
- //contents have moved pendingLineMove rows up
- setContentsPos (0, contentsY()-(pendingLineMove*cellHeight()));
-
- //enable repainting here
- setUpdatesEnabled (true);
-
- //request repaint here
- //If we've added less than 10 lines since last repaint , we request an update, \
which will be
- //performed when the app returns to main event queue.
- //If, however, >=10 lines have been added since last repaint, we ask for an \
instant repaint.
- //The purpose of this policy is to prevent the "black-out" effect, that can happen \
when lot
- //of lines is received at once - the text gets blacked out while we process the \
text, then
- //it gets filled with latest text after text adding is done.
- //UPDATE: not 10 lines, but a configurable amount
- if (repaintCount)
- {
- if (newlineCounter < repaintCount)
- updateContents ();
- else
- repaintContents ();
- }
- else
- {
- newlineCounter = 0;
- updateContents ();
- }
-
- if (!aux)
- aconsole->addNewText (storedChunk, endTheLine);
-}
-
-void cConsole::handleBufferShift()
-{
- //move selection if needed
- if (selected)
- {
- selrow1--;
- selrow2--;
-
- if (selrow1 < 0) selrow1 = 0;
- if (selrow2 < 0) selrow2 = 0;
- }
+void cConsole::setFont (QFont f) {
+ d->font = f;
+ d->text->setDefaultFont (d->font);
- //no cache for aconsole
- if (!aux)
- {
- for (int i = 0; i < MAXCACHE; i++)
- {
- if (cacheBlinkOn[i] != 0)
- {
- cacheEntry[i]--;
- if (cacheEntry[i] < 0)
- deleteCacheEntry (i);
- }
- }
- }
+ QFontMetrics fm (f);
+ d->charWidth = fm.width ("m");
+ d->charHeight = fm.lineSpacing();
- //shift buffer - done automatically by cHistoryBuffer :-)
+ fixupOutput();
}
-void cConsole::endLine ()
-{
- currowpos = 0;
- pendingLineMove++;
- newlineCounter++;
- if (currow < historySize - 1)
- currow++;
- else
- handleBufferShift ();
-
- //add a new empty line
- cTextChunk *chunk = new cTextChunk (this);
- buffer->add (chunk);
-
- usedrows = currow + 1;
+QFont cConsole::font () {
+ return d->font;
}
-void cConsole::forceBeginOfLine ()
-{
- if (currowpos > 0)
- endLine ();
- if (!aux)
- aconsole->forceBeginOfLine ();
+void cConsole::setDefaultBkColor (QColor color) {
+ d->bgcolor = color;
+ QPalette pal = palette();
+ pal.setColor (backgroundRole(), d->bgcolor);
+ pal.setColor (QPalette::Base, d->bgcolor);
+ setPalette (pal);
+ update();
}
-void cConsole::dumpBuffer (bool fromcurrent, FILE *file, char dumpType)
-{
- //file must be opened for writing!
- //headers must also be written in case of HTML dump...
-
- //get visible range
- int y = contentsY();
- int row = rowAt (y);
- int start = fromcurrent ? row : 0;
-
- cANSIParser *ap = dynamic_cast<cANSIParser *>(cActionManager::self()->object \
("ansiparser", sess));
-
- for (int i = start; i <= currow; i++)
- {
- //proceed line by line
- cTextChunk *chunk = (*buffer)[i];
- if (chunk)
- switch (dumpType) {
- case TRANSCRIPT_PLAIN: fputs (chunk->toText().toLocal8Bit(), file); break;
- case TRANSCRIPT_ANSI: fputs (chunk->toAnsi(ap).toLocal8Bit(), file); break;
- case TRANSCRIPT_HTML: fputs (chunk->toHTML().toLocal8Bit(), file); break;
- };
- }
+QColor cConsole::defaultBkColor () {
+ return d->bgcolor;
}
-void cConsole::tryUpdateHistorySize ()
+void cConsole::setScrollTextSize (int aconsize)
{
- if (currow == -1)
- clear ();
+ // TODO
}
-void cConsole::paintCell (QPainter *p, int row, int)
-{
- //reset newline counter
- newlineCounter = 0;
-
- if (row < usedrows) //only the first "usedrows" rows contain data
- {
- int cw = QTableView::cellWidth ();
- int ch = cellHeight ();
-
- QPixmap *pix = 0, *pix2 = 0;
-
- //if this line is selected (partially selected), do NOT use cache!
- bool forceNoCache = false;
- int ss1, ss2, sp1, sp2;
- ss1 = selrow1; ss2 = selrow2;
- sp1 = selrowpos1; sp2 = selrowpos2;
- if (ss1 > ss2)
- {
- swap (ss1, ss2);
- swap (sp1, sp2);
- }
- if ((ss1 == ss2) && (sp1 > sp2))
- swap (sp1, sp2);
- if (selected && (ss1 <= row) && (ss2 >= row))
- forceNoCache = true;
- if (aux) //no cache for auxiliary console
- forceNoCache = true;
-
- //try to find the pixmap in the cache first...
- bool foundInCache = false;
- if (!forceNoCache)
- for (int i = 0; i < MAXCACHE; i++)
- if ((cacheBlinkOn[i] != NULL) && (cacheEntry[i] == row))
- {
- foundInCache = true;
- if (blinking)
- {
- pix = cacheBlinkOn[i];
- pix2 = cacheBlinkOff[i];
- }
- else
- pix = cacheBlinkOn[i];
- break;
- }
-
- //look if there are any blinking chars
- bool hasblink = hasBlink (row);
- //if search fails, we have to draw that line :(
- //if we'll be putting it into cache and there are blinking chars in the
- //line, then we'll construct both blinkOn and blinkOff line
- if (!foundInCache)
- {
- //We create both entries even if blinking is disabled, because user
- //can enable it at any time. This can have impact on performance -
- //maybe I'll change this behavior?
-
- pix = new QPixmap (cw, ch);
- pix->fill (bgcolor);
- QPainter *p2 = new QPainter (pix);
-
- QPainter *p2b = 0;
- if (hasblink)
- {
- //pix2 and p2b represent pixmap with hidden blinking letters
- pix2 = new QPixmap (cw, ch);
- pix2->fill (bgcolor);
- p2b = new QPainter (pix2);
- }
-
- //prepare arguments and paint the row!
- cTextChunk *chunk = (*buffer)[row];
- int selstart = -1;
- int sellen = 0;
- if (selected && (ss1 <= row) && (ss2 >= row))
- {
- selstart = (ss1 == row) ? sp1 : 0;
- sellen = (ss2 == row) ? (sp2 - selstart + 1) : (charCount - selstart);
- }
- chunk->paint (charCount, selstart, sellen, charWidth, cellHeight() - descent - \
1, p2, p2b);
-
- p2->end ();
- delete p2;
- if (hasblink)
- {
- p2b->end();
- delete p2b;
- }
-
- //Good. Now add this pixmap to the cache (if allowed).
- if (!forceNoCache)
- {
- int idx = -1;
- for (int i = 0; i < MAXCACHE; i++)
- if (cacheBlinkOn[i] == 0)
- {
- idx = i;
- break;
- }
- if (idx == -1) //cache is FULL - create space!
- {
- deleteCacheEntry (0);
- for (int i = 0; i < MAXCACHE - 1; i++)
- {
- cacheBlinkOn[i] = cacheBlinkOn[i+1];
- cacheBlinkOff[i] = cacheBlinkOff[i+1];
- cacheEntry[i] = cacheEntry[i+1];
- }
- //we'll add a new entry at the free position
- idx = MAXCACHE - 1;
- }
- cacheEntry[idx] = row;
- cacheBlinkOn[idx] = pix;
- if (hasblink)
- cacheBlinkOff[idx] = pix2;
- else
- cacheBlinkOff[idx] = pix;
- }
- }
-
- if (blinking && hasblink)
- p->drawPixmap (QPoint (0, 0), blinkPhase ? (*pix) : (*pix2),
- QRect (0, 0, cw, ch));
- else
- p->drawPixmap (QPoint (0, 0), *pix, QRect (0, 0, cw, ch));
-
- //if pix is not in the cache, then we have to delete it!
- //the same for pix2
- if (forceNoCache)
- {
- delete pix;
- if (hasblink)
- delete pix2;
- }
- }
- //else we do nothing...
- else
- return;
+void cConsole::setIndentation (int val) {
+ // TODO
}
-void cConsole::fixupOutput ()
-{
- //cache is no longer valid
- emptyCache ();
-
- //compute new number of columns
- QSize wsize = viewportSize (width(), height());
- int newcols = wsize.width() / charWidth;
- int spaceforrows = wsize.height() / cellHeight ();
- QTableView::setCellWidth (newcols * charWidth);
-
- //columns are handled first... no manipulation needed anymore, as the paint \
routines are
- //more intelligent now :D
- if (newcols != charCount)
- charCount = newcols;
-
- //rows don't need much manipulation...
- setNumRows (usedrows);
+void cConsole::setEnableBlinking (bool value) {
+ // TODO
+}
- if (!aux)
- {
- int value = verticalScrollBar()->value ();
- int maxval = verticalScrollBar()->maximum ();
- if ((value != maxval) && (!aconvisible)) //resize led to contents shift - move \
to bottom
- verticalScrollBar()->setValue (verticalScrollBar()->maximum());
- }
-
- //set auxiliary console geometry, if needed
- if (!aux)
- {
- //geometry is relative to parent widget - that's the console object
- aconsole->setGeometry (0, height() - height() * aconsize / 100,
- width() - verticalScrollBar()->width(), height() * aconsize / 100);
- //height()*(100-aconsize)/100 can NOT be used in param 2,
- //as it may cause one-pixel shift, because integer division
- //is not accurate (A*3/4 + A/4 is not always A)
- aconsole->fixupOutput();
- }
-
- //inform others about the changes; telnet with NAWS should be connected here...
- if (!aux)
- {
- currows = spaceforrows;
- curcols = newcols;
- emit dimensionsChanged (newcols, spaceforrows);
- }
-
- //update the widget
- viewport()->update ();
- updateContents ();
+int cConsole::curRows() {
+ return height() / d->charHeight;
}
-void cConsole::resizeEvent (QResizeEvent *e)
-{
- //let the parent process it first
- QTableView::resizeEvent (e);
-
- //fixup output window to reflect changes
- fixupOutput ();
+int cConsole::curCols() {
+ if (d->charWidth <= 0) return 0;
+ return width() / d->charWidth;
}
-void cConsole::updateRowRange (int r1, int r2)
-{
- int rr1 = r1;
- int rr2 = r2;
- if (rr1 > rr2)
- swap (rr1, rr2);
- for (int i = rr1; i <= rr2; i++)
- updateCell (i, 0);
+void cConsole::setRepaintCount (int val) {
+ // TODO
}
-void cConsole::mousePressEvent (QMouseEvent *e)
-{
- if (e->button() == Qt::LeftButton)
- {
- //clear old selection first
- if (selected)
- {
- selected = false;
- updateRowRange (selrow1, selrow2);
- }
-
- if (!triple_click_time.isNull()
- && triple_click_time.elapsed() < QApplication::doubleClickInterval())
- {
- mouseTripleClickEvent (e);
- //nothing more to do - we mustn't proceed, as further code would destroy our \
selection
- return;
- }
- if (numRows() == 0)
- return;
-
- int inrow = rowAt (e->y());
- int incol = e->x() / charWidth;
- if (incol >= charCount)
- incol = charCount;
- if (incol < 0)
- incol = 0;
- if (inrow < 0)
- inrow = 0;
- if (inrow >= numRows())
- inrow = numRows() - 1;
- //do not crash if widget is still empty
- if ((inrow < 0) || (incol < 0))
- return;
- previousr = selrow2 = selrow1 = inrow;
- previousc = selrowpos2 = selrowpos1 = incol;
- canselect = true;
- selected = false;
- }
- else
- if (e->button() == Qt::MidButton)
- {
- if (aux)
- //auxiliary console won't process this, it will leave it for main
- //console (it's a parent of aconsole)
- e->ignore();
- else
- {
- //middle button scrolls to bottom, leaving split-screen mode
- verticalScrollBar()->setValue (verticalScrollBar()->maximum());
- e->accept();
- }
- }
+void cConsole::forceEmitSize () {
+ emit dimensionsChanged (curCols(), curRows());
}
-void cConsole::mouseReleaseEvent (QMouseEvent *e)
-{
- if (e->button() == Qt::LeftButton)
- {
- canselect = false;
-
- //click on a link?
- int inrow = rowAt (e->y());
- int incol = e->x() / charWidth;
- //do not crash if widget is still empty
- if ((inrow < 0) || (incol < 0) || (numRows() == 0))
- return;
- cTextChunk *chunk = (*buffer)[inrow];
- if (chunk)
- {
- chunkItem *item = chunk->itemAt (incol);
- if (item && (item->type() == CHUNK_LINK))
- activateLink ((chunkLink *) item, e->globalPos());
- }
-
- }
- /*
- else if (e->button() == Qt::MidButton) {
- //TODO: maybe Ctrl+MidButton to scroll down, MidButton to paste ?
- QString command = \
(KApplication::kApplication())->clipboard()->text(QClipboard::Selection);
- addCommand(command);
- }
- */
+void cConsole::dumpBuffer (bool fromcurrent, FILE *file, char dumpType) {
+ // TODO
}
-void cConsole::mouseMoveEvent (QMouseEvent *e)
-{
- //changing cursor over links...
- int inrow = rowAt (e->y());
- int incol = e->x() / charWidth;
- //do not crash if widget is still empty
- if ((inrow < 0) || (incol < 0) || (numRows() == 0))
- return;
- cTextChunk *chunk = (*buffer)[inrow];
- if (chunk)
- {
- chunkItem *item = chunk->itemAt (incol);
- if (item && (item->type() == CHUNK_LINK))
- //we're over some link -> we show a hand
- viewport()->setCursor (Qt::PointingHandCursor);
- else
- viewport()->setCursor (Qt::IBeamCursor);
- }
- if (canselect)
- {
- if (incol >= charCount)
- incol = charCount;
- if (incol < 0)
- incol = 0;
- if (inrow < 0)
- inrow = 0;
- if (inrow >= numRows())
- inrow = numRows() - 1;
- previousr = selrow2;
- previousc = selrowpos2;
- selrow2 = inrow;
- selrowpos2 = incol;
- if ((inrow != previousr) || (incol != previousc))
- //moved mouse to another cell while pressing button
- {
- selected = true;
-
- //update all selected cells:
- updateRowRange (previousr, selrow2);
-
- //put selected text to mouse selection...
- addSelectionToClipboard (QClipboard::Selection);
- }
- }
+void cConsole::tryUpdateHistorySize () {
+ // TODO
}
-void cConsole::mouseDoubleClickEvent (QMouseEvent *e)
-{
- if (e->button() == Qt::LeftButton)
- {
- triple_click_time.start();
- //clear old selection first - there should be none, as mousePress handler
- //has already been called, but I want to be sure...
-
- //FIXME: Why on earth are we checking/clearing selected again - waste!?
- //Same issue with triple click - to get to these, you have to go
- //through mousePress - in what instance would it ever be possible
- //that selected is _not_ cleared?
- // (Tomas) Well, you just never know... ;)
- if (selected)
- {
- selected = false;
- updateRowRange (selrow1, selrow2);
- (KApplication::kApplication())->processEvents ();
- }
-
- int inrow = rowAt (e->y());
- int incol = e->x() / charWidth;
- if (incol >= charCount)
- incol = charCount;
- if (incol < 0)
- incol = 0;
- if (inrow < 0)
- inrow = 0;
- if (inrow >= numRows())
- inrow = numRows() - 1;
- //do not crash if widget is still empty
- if ((inrow < 0) || (incol < 0))
- return;
- previousr = selrow2 = selrow1 = inrow;
- canselect = false;
-
- //fetch the string on that row
- QString s = (*buffer)[inrow]->plainText ();
- if (incol >= s.length())
- return;
- int len = s.length();
-
- //find the whole word, if we've clicked in one... More than one row
- //can never be selected.
- QChar ch = s[incol];
- if (ch.isLetterOrNumber() || (ch == '_'))
- {
- int index;
- //find the beginning
- index = incol;
- while (ch.isLetterOrNumber() || (ch == '_'))
- {
- if (index == 0)
- break;
- ch = s[--index];
- }
- if (!(ch.isLetterOrNumber() || (ch == '_')))
- index++;
- selrowpos1 = (index >= 0) ? index : 0; //set beginning of selection
- //and the end of the text
- index = incol;
- ch = s[incol];
- while (ch.isLetterOrNumber() || (ch == '_'))
- {
- if (index == len - 1)
- break;
- ch = s[++index];
- }
- if (!(ch.isLetterOrNumber() || (ch == '_')))
- index--;
- selrowpos2 = (index < len) ? index : len;
- //set end of selection
-
- selected = true;
-
- //update all selected cells:
- updateRowRange (selrow1, selrow2);
-
- //put selected text to mouse selection...
- addSelectionToClipboard (QClipboard::Selection);
- }
- else
- {
- previousc = selrowpos2 = selrowpos1 = incol;
- selected = false;
- }
- }
+void cConsole::setInitialHistorySize (int size) {
+ // TODO
}
-//Select entire text line on triple click
-void cConsole::mouseTripleClickEvent (QMouseEvent *e)
-{
- //FIXME: Why on earth are we checking selected again - waste!?
- if (selected) {
- selected = false;
- updateRowRange(selrow1, selrow2);
- (KApplication::kApplication())->processEvents();
- }
- int inrow = rowAt(e->y());
+QStringList cConsole::words (QString prefix, int minLength) {
+ QStringList res;
- // ensure that the row number is correct - usually only needed in the
- // beginning, when there are very little or no rows
- if (numRows() == 0)
- return;
- if (inrow < 0)
- inrow = 0;
- if (inrow >= numRows())
- inrow = numRows() - 1;
+ // TODO
-
- QString textLine = (* buffer) [inrow]->plainText();
-
- if (!textLine.isNull()) {
- //select the whole line!
-
- previousr = selrow2 = selrow1 = inrow;
- canselect = false;
- selected = true;
- selrowpos1 = 0;
- selrowpos2 = textLine.length() - 1;
-
- //update all selected cells:
- updateRowRange (selrow1, selrow2);
-
- //put selected text to mouse selection...
- addSelectionToClipboard (QClipboard::Selection);
- }
-}
-
-void cConsole::wheelEvent (QWheelEvent *e)
-{
- /*
- Our parent processes whell event correctly, but there's one problem.
- If this is an auxiliary console, it shouldn't be scrollable, but the
- default wheelEvent implementation doesn't know it and scrolls.
-
- My solution is to process whelel event for the standard console by
- default handler and to ignore it by aconsole. Then it gets to the parent
- widget (main console), which processes it. It means that even if you
- use the wheel in aconsole region, main console gets scrolled, which is
- exactly what we want.
- */
- if (!aux)
- QTableView::wheelEvent (e);
- else
- e->ignore ();
+ return res;
}
-bool cConsole::event (QEvent *e)
-{
- if (e->type() == QEvent::ToolTip) {
- QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e);
- QPoint point = helpEvent->pos();
-
- //we'll show some tooltip...
- int inrow = rowAt (contentsY() + point.y());
- if ((inrow >= 0) && (inrow < numRows())) {
- //get the timestamp
- QString tipText = (*buffer)[inrow]->getTimeStamp();
- //show the tip!
- QToolTip::showText (helpEvent->globalPos(), tipText, this);
- } else
- QToolTip::hideText();
- }
- return QWidget::event(e);
+void cConsole::clear () {
+ d->text->clear();
+ update();
}
-void cConsole::activateLink (chunkLink *link, const QPoint &point)
-{
- //two modes of operation, depending on whether this is a command-link or a \
URL-link
- if (link->isCommand())
- {
- QString cmd = link->target();
- bool toprompt = link->toPrompt();
- bool ismenu = link->isMenu();
- if (ismenu)
- {
- //get rid of old menu, if any
- delete linkMenu;
-
- link->parseMenu();
-
- //create the menu
- menuChunk = link;
- linkMenu = new KMenu (this);
-
- //insert all the items
- list<menuItem>::const_iterator it;
- for (it = menuChunk->menu().begin(); it != menuChunk->menu().end(); ++it)
- linkMenu->addAction ((*it).caption);
- connect (linkMenu, SIGNAL (triggered (QAction *)), this, SLOT \
(linkMenuItemHandler (QAction *)));
-
- linkMenu->popup (point);
- }
- else
- {
- if (toprompt)
- emit promptCommand (cmd);
- else
- emit sendCommand (cmd);
- }
- }
- else
- {
- QString url = link->target();
- KToolInvocation::invokeBrowser (url);
- }
+void cConsole::addLine (cTextChunk *chunk) {
+ addNewText (chunk, true);
}
-void cConsole::linkMenuItemHandler (QAction *item)
-{
- if (!linkMenu) return;
- int idx = linkMenu->actions().indexOf (item);
- if (idx == -1) return; // not found
- bool toprompt = menuChunk->toPrompt();
- list<menuItem>::const_iterator it;
- QString cmd;
- it = menuChunk->menu().begin();
- for (int i = 0; i < idx; i++)
- ++it;
- cmd = (*it).command;
- if (toprompt)
- emit promptCommand (cmd);
- else
- emit sendCommand (cmd);
-
- linkMenu = 0;
- menuChunk = 0;
+void cConsole::addText (cTextChunk *chunk) {
+ addNewText (chunk, false);
}
-void cConsole::addSelectionToClipboard (QClipboard::Mode clipboardMode)
+void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
{
- if (selected)
- {
- QString text = "";
- int r1 = selrow1;
- int r2 = selrow2;
- int c1 = selrowpos1;
- int c2 = selrowpos2;
- int start = r1 * charCount + c1;
- int end = r2 * charCount + c2;
- if (start > end)
- {
- swap (r1, r2);
- swap (c1, c2);
- }
- for (int i = r1; i <= r2; i++)
- {
- QString line = (*buffer)[i]->plainText();
- int len = line.length();
- if (i == r1) line.remove (0, c1);
- if (i == r2) line.truncate (line.length() - (len - c2 - 1));
- //add a \n, unless it's a last line
- if (i < r2)
- line += '\n';
- //and add this line to the resulting text
- text += line;
- }
- //now I have the whole text - put it to the clipboard!
- if (text.length() > 0 && !text.isNull())
- {
- QClipboard *clip = (KApplication::kApplication())->clipboard ();
-
- clip->setText(text,clipboardMode);
- //If text is being copied into Global Clipboard (ie non-selection)
- //this clears the selected text from the screen
- if (clipboardMode == QClipboard::Clipboard) {
- selected = false;
- updateRowRange (selrow1, selrow2);
- }
+ QTextCursor cursor (d->text);
+ cursor.movePosition (QTextCursor::End);
+ if (chunk) {
+ if (d->wantNewLine) {
+ cursor.insertBlock ();
+ d->wantNewLine = false;
}
- }
-}
-
-void cConsole::expireNamedLinks (const QString &name)
-{
- //this may be a bit slow if used too often...
- //get visible range
- int y1 = contentsY();
- int y2 = y1 + contentsHeight() - 1;
- int row1 = rowAt (y1);
- int row2 = rowAt (y2);
-
- for (int i = 0; i <= currow; i++)
- {
- //proceed line by line
- cTextChunk *chunk = (*buffer)[i];
- bool expired = chunk->expireNamedLinks (name);
- if (expired)
- {
- //this line must be deleted from the drawing cache, if it's there
- deleteLineFromCache (i);
- //repaint row if it's visible
- if ((row1 <= i) && (row2 >= i))
- updateCell (i, 0);
- }
+ cursor.insertHtml (chunk->toHTML());
}
+ if (endTheLine) d->wantNewLine = true;
}
-
-//the following functions are not implemented using {add/subtract}{Line/Page},
-//because pageStep cannot be redefined in QGridView (no idea why). So I
-//have to do this manually...
-
-void cConsole::lineUp ()
-{
- QScrollBar *s = verticalScrollBar ();
- s->setValue (s->value() - cellHeight ());
-}
-
-void cConsole::lineDown ()
-{
- QScrollBar *s = verticalScrollBar ();
- s->setValue (s->value() + cellHeight ());
-}
-
-void cConsole::pageUp ()
-{
- QScrollBar *s = verticalScrollBar ();
- s->setValue (s->value() - (height() - height() / 4) * 9/10);
+void cConsole::forceBeginOfLine () {
+ addNewText (nullptr, true);
}
-void cConsole::pageDown ()
-{
- QScrollBar *s = verticalScrollBar ();
- s->setValue (s->value() + (height() - height() / 4) * 9/10);
+void cConsole::expireNamedLinks (const QString &name) {
+ // TODO
}
-void cConsole::aconUp ()
-{
- //85% is max size
- if (aconsize <= 80)
- aconsize += 5;
- else
- return;
-
- //set auxiliary console geometry, if needed
- if (!aux)
- {
- //geometry is relative to parent widget - that's the console object
- aconsole->setGeometry (0, height() - height() * aconsize / 100,
- width() - verticalScrollBar()->width(), height() * aconsize / 100);
- //height()*(100-aconsize)/100 can NOT be used in param 2,
- //as it may cause one-pixel shift, because integer division
- //is not accurate (A*3/4 + A/4 is not always A)
- //no need to move contents here, because it'll be done automatically
- // (we're always at the very bottom)
- }
+void cConsole::addSelectionToClipboard (QClipboard::Mode clipboardMode) {
+ // TODO
}
-void cConsole::aconDown ()
-{
- int oldaconsize = aconsize;
- //5% is min size
- if (aconsize >= 10)
- aconsize -= 5;
- else
- return;
-
- //set auxiliary console geometry, if needed
- if (!aux)
- {
- int newy = height() - height() * aconsize / 100;
- int oldy = height() - height() * oldaconsize / 100;
-
- //geometry is relative to parent widget - that's the console object
- aconsole->setGeometry (0, newy,
- width() - verticalScrollBar()->width(), height() * aconsize / 100);
- //height()*(100-aconsize)/100 can NOT be used in param 2,
- //as it may cause one-pixel shift, because integer division
- //is not accurate (A*3/4 + A/4 is not always A)
-
- //we also need to move contents
-
- aconsole->scrollBy (0, newy - oldy);
- }
+void cConsole::lineUp () {
+ // TODO
}
-void cConsole::sliderChanged (int value)
-{
- int maxval = verticalScrollBar()->maximum ();
- if ((value == maxval) && (aconvisible))
- {
- aconsole->hide ();
- aconvisible = false;
- repaintContents (false);
- }
- if ((value != maxval) && (!aconvisible))
- {
- aconsole->show ();
- aconvisible = true;
- }
+void cConsole::lineDown () {
+ // TODO
}
-void cConsole::deleteLineFromCache (int line)
-{
- if ((line < 0) || (line > currow))
- return;
- for (int i = 0; i < MAXCACHE; i++)
- if (cacheEntry[i] == line)
- deleteCacheEntry (i);
+void cConsole::pageUp () {
+ // TODO
}
-void cConsole::deleteCacheEntry (int which)
-{
- if ((which < 0) || (which >= MAXCACHE))
- return;
- if (aux) //no cache for aconsole
- return;
- if (cacheBlinkOn[which] != 0)
- {
- cacheEntry[which] = 0;
- //no blinking here
- if ((cacheBlinkOn[which] == cacheBlinkOff[which]) || (cacheBlinkOff[which] == \
0))
- {
- delete cacheBlinkOn[which];
- cacheBlinkOff[which] = 0;
- cacheBlinkOn[which] = 0;
- }
- else
- {
- delete cacheBlinkOff[which];
- delete cacheBlinkOn[which];
- cacheBlinkOff[which] = 0;
- cacheBlinkOn[which] = 0;
- }
- }
+void cConsole::pageDown () {
+ // TODO
}
-void cConsole::emptyCache ()
+void cConsole::resizeEvent (QResizeEvent *)
{
- if (aux) //no cache for aconsole
- return;
- for (int i = 0; i < MAXCACHE; i++)
- deleteCacheEntry (i);
+ fixupOutput();
}
-bool cConsole::hasBlink (int row)
+void cConsole::fixupOutput ()
{
- if ((row < 0) || (row >= usedrows))
- return false;
- cTextChunk *chunk = (*buffer)[row];
- if (chunk == 0) //that row does not exist yet
- return false;
- bool hb = false;
- list<chunkItem *> entries = chunk->entries();
- list<chunkItem *>::iterator it;
- for (it = entries.begin(); it != entries.end(); ++it)
- if ((*it)->type() == CHUNK_ATTRIB)
- if (((chunkAttrib *) (*it))->attrib() & ATTRIB_BLINK)
- {
- hb = true;
- break;
- }
- return hb;
-}
+ d->text->setTextWidth (d->scene.width());
-void cConsole::forceEmitSize ()
-{
- emit dimensionsChanged (curcols, currows);
+ forceEmitSize ();
}
-void cConsole::blinkTimerTimeout ()
-{
- //switch state
- blinkPhase = blinkPhase ? false : true;
-
- //get visible range
- int y1 = contentsY();
- int y2 = y1 + contentsHeight() - 1;
- int row1 = rowAt (y1);
- int row2 = rowAt (y2);
- //for each row
- for (int i = row1; i < row2; i++)
- {
- //look if it contains blinking characters
- if (hasBlink (i))
- //if it does, redraw it
- updateCell (i, 0);
- }
-}
+/*
+TODO SIGNALS - these must be emitted
+void sendCommand (const QString &command); -- in activateLink
+void promptCommand (const QString &command); -- in activateLink
+*/
-#include "cconsole.moc"
diff --git a/libs/cconsole.h b/libs/cconsole.h
index 14bbdc6..9ddd536 100644
--- a/libs/cconsole.h
+++ b/libs/cconsole.h
@@ -2,9 +2,9 @@
cconsole.h - main displaying widget
This file is a part of KMuddy distribution.
-------------------
- begin : So Jun 22 2002
- copyright : (C) 2002-2004 by Tomas Mecir
- email : kmuddy@kmuddy.com
+ begin : So Jun 22 2017
+ copyright : (C) 2002-2017 by Tomas Mecir
+ email : mecirt@gmail.com
***************************************************************************/
/***************************************************************************
@@ -16,113 +16,56 @@
* *
***************************************************************************/
-#define TRANSCRIPT_PLAIN 2
-#define TRANSCRIPT_ANSI 3
-#define TRANSCRIPT_HTML 1
-
#ifndef CCONSOLE_H
#define CCONSOLE_H
-#include <QTableView>
-#include <qclipboard.h>
-#include <qdatetime.h>
-
-#include <stdio.h>
+#define TRANSCRIPT_PLAIN 2
+#define TRANSCRIPT_ANSI 3
+#define TRANSCRIPT_HTML 1
#include <kmuddy_export.h>
-class QEvent;
-class QPainter;
-class QPixmap;
-class KMenu;
-class KToggleAction;
-
+#include <QClipboard>
+#include <QGraphicsView>
+#include <QStringList>
class cTextChunk;
-class chunkLink;
-
-/**
-Class cHistoryBuffer - holds the whole buffer, rotates it when needed and provides \
access to it.
-Inspired by a similar class from Alex Bache.
-*/
-
-class KMUDDY_EXPORT cHistoryBuffer {
- public:
- /** create the cyclic buffer of a given size */
- cHistoryBuffer (int size);
- /** destructor */
- ~cHistoryBuffer ();
- /** current number of items in the buffer */
- int items () { return _items; };
- /** current size of the buffer */
- int size () { return _size; };
- /** add a new line to the buffer */
- void add (cTextChunk *chunk);
- /** Returns one line in the buffer.
- Returns cTextChunk*, not cTextChunk*& - so that we can modify the chunk contents, \
but we
- cannot assign another chunk to any given position,*/
- cTextChunk * operator[] (int idx);
- /** flush the buffer */
- void flush ();
- protected:
- int _size, _items;
- /** position in the cyclic buffer, where the NEXT added item will go */
- int curidx;
- /** the actual buffer */
- cTextChunk **buffer;
-};
//maximum cache size
#define MAXCACHE 50
/**
Main console - displays output of the MUD server...
-Inherits QGridView - has one column and one row per line (each cell contains
-one line of text - removes flicker)
-
-Includes another cConsole object - used to display last few lines of output
-while scrolling the main console...
- *@author Tomas Mecir
- */
+This is a new version of the displaying widget, replacing the old QTableView-based \
widget. +*/
-class KMUDDY_EXPORT cConsole : public QTableView {
+class KMUDDY_EXPORT cConsole : public QGraphicsView {
Q_OBJECT
public:
- /** auxiliary console is used to display last few lines when scrolling... */
- cConsole(bool auxiliary=false, QWidget *parent=0);
+ cConsole(QWidget *parent = Q_NULLPTR);
~cConsole();
void setSession (int s);
- /** get auxiliary console */
- cConsole *auxConsole ();
-
/** set font */
void setFont (QFont f);
/** get currently used font */
- QFont font () { return myfont; };
+ QFont font ();
void setDefaultBkColor (QColor color);
- QColor defaultBkColor () { return bgcolor; };
+ QColor defaultBkColor ();
- void setWordWrapping (bool val);
void setIndentation (int val);
-
void setEnableBlinking (bool value);
- int wrapPos() { return wrappos; };
- void setWrapPos (int wp);
-
- int numCols () { return charCount; };
- void setNumCols (int numcols) { charCount = numcols; };
- int cellWidth () { return charWidth; };
- void setCellWidth (int) { /* do nothing! */ };
-
/** return current number of rows */
- int curRows() { return currows; };
+ int curRows();
/** return current number of columns */
- int curCols() { return curcols; };
+ int curCols();
+
+ /** Size of the secondary console shown while scrolling */
+ void setScrollTextSize (int aconsize);
/** number of lines until a forced repaint */
- void setRepaintCount (int val) { repaintCount = val; };
+ void setRepaintCount (int val);
/** forces amission of dimensionsChanged signal; used by toolbar hiding
functions, where this fails for unknown reasons */
@@ -130,7 +73,7 @@ public:
/** dump all history buffer to that file */
void dumpBuffer (bool fromcurrent, FILE *file, char dumpType);
void tryUpdateHistorySize ();
- static void setInitialHistorySize (int size) { initHistory = size; };
+ void setInitialHistorySize (int size);
QStringList words (QString prefix, int minLength = 3);
/** clear the widget */
@@ -141,13 +84,13 @@ public:
void addText (cTextChunk *chunk);
/** ensure that our current position is at beginning of a line */
void forceBeginOfLine ();
- /** adds selection to clipboard (adding to mouse selection buffer is done
- automatically) */
/** expire all links with a given name, or all named links if no name given */
void expireNamedLinks (const QString &name = QString());
public slots:
+ /** adds selection to clipboard (adding to mouse selection buffer is done
+ automatically) */
void addSelectionToClipboard (QClipboard::Mode clipboardMode);
/** shifting it around (SHIFT+keys) */
@@ -156,136 +99,20 @@ public slots:
void pageUp ();
void pageDown ();
- /** resizing aconsole (CTRL+keys) */
- void aconUp ();
- void aconDown ();
signals:
void dimensionsChanged (int cols, int rows);
void sendCommand (const QString &command);
void promptCommand (const QString &command);
-protected slots:
- void sliderChanged (int value);
- void blinkTimerTimeout ();
- /** handler for the link menu */
- void linkMenuItemHandler (QAction *item);
+
protected:
- /** called when a cell is to be painted */
- void paintCell (QPainter *p, int row, int);
- /** resize event */
- void resizeEvent (QResizeEvent *e);
+ void resizeEvent (QResizeEvent *e) override;
/** called when resizing and when changing font */
void fixupOutput ();
- /** updates a range of cells - used in events below */
- void updateRowRange (int r1, int r2);
-
- /** mouse press event */
- void mousePressEvent (QMouseEvent *e);
- /** mouse release event */
- void mouseReleaseEvent (QMouseEvent *e);
- /** mouse move event */
- void mouseMoveEvent (QMouseEvent *e);
- /** mouse double-click event */
- void mouseDoubleClickEvent (QMouseEvent *e);
- /** mouse triple-click event */
- void mouseTripleClickEvent (QMouseEvent *e);
- /** disables scrolling aux.console using mouse wheel */
- void wheelEvent (QWheelEvent *e);
- /** Event catch-all, used to catch the tooltip event. */
- bool event (QEvent *e);
- /** activate a link - called when user clicks on it */
- void activateLink (chunkLink *link, const QPoint &point);
-
- /** add new text; called by addLine and addText */
void addNewText (cTextChunk *chunk, bool endTheLine);
- /** handles necessary updates when new line needs to be created */
- void handleBufferShift ();
- /** end current line */
- void endLine ();
- /** make the redrawing cache empty */
- void emptyCache ();
- /** delete one line (=row) from the redrawing cache */
- void deleteLineFromCache (int line);
- /** delete one item from the cache */
- void deleteCacheEntry (int which);
-
- /** are there blinking characters on that line? */
- bool hasBlink (int row);
-
- QPixmap *cacheBlinkOn[MAXCACHE], *cacheBlinkOff[MAXCACHE];
- int cacheEntry[MAXCACHE];
- /** ON = blinking text shown, OFF = blinking text hidden */
- bool blinkPhase;
- QTimer *blinkTimer;
-
- KToggleAction *fullscreenmode, *showmenubar;
-
- //triple click time
- QTime triple_click_time;
-
- /** background color */
- QColor bgcolor;
-
- /** wordwrapping / indentation / wrap position */
- bool wordWrapping;
- int indentValue, wrappos;
-
- /** new-line counters - used to prevent the "black-out" effect */
- int repaintCount, newlineCounter;
-
- /** blinking ON/OFF */
- bool blinking;
-
- /** currently used font */
- QFont myfont;
- /** descent of the currently used font, needed for drawing */
- int descent;
- /** width of one character */
- int charWidth;
- /** number of characters in one line */
- int charCount;
-
- /** number of added rows during current addNewText call */
- int pendingLineMove;
-
- /** current console size */
- int currows, curcols;
-
- /** session */
- int sess;
-
- /** our auxiliary console */
- cConsole *aconsole;
-
- /** are WE the auxiliary console? */
- bool aux;
- /** is the auxiliary console visible? */
- bool aconvisible;
- /** size of auxiliary console (in percents) */
- int aconsize;
-
- //is the hand cursor displayed (over a link)?
- bool ishandcursor;
-
- /** the link menu */
- chunkLink *menuChunk;
- KMenu *linkMenu;
-
- //selection
- int selrow1, selrow2, selrowpos1, selrowpos2;
- int previousr, previousc;
- bool selected, canselect;
-
- /** initial history size */
- static int initHistory;
-
- //THE DATA
- int usedrows;
- int currow;
- int currowpos;
- int historySize;
- cHistoryBuffer *buffer;
+ class Private;
+ Private *d;
};
#endif
diff --git a/libs/cdownloader.cpp b/libs/cdownloader.cpp
index 2f2d1c9..e6617bf 100644
--- a/libs/cdownloader.cpp
+++ b/libs/cdownloader.cpp
@@ -75,5 +75,3 @@ void cDownloader::slotResult (KIO::Job *job)
currentJob = 0;
}
-#include "cdownloader.moc"
-
diff --git a/libs/cexpresolver.cpp b/libs/cexpresolver.cpp
index 080a0e9..09b37b4 100644
--- a/libs/cexpresolver.cpp
+++ b/libs/cexpresolver.cpp
@@ -26,7 +26,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include "cmacromanager.h"
#include "cvariablelist.h"
-#include <klocale.h>
+#include <KLocalizedString>
cExpResolver::cExpResolver (int _sess)
{
diff --git a/libs/cglobalsettings.cpp b/libs/cglobalsettings.cpp
index c15b6cd..ba65a1d 100644
--- a/libs/cglobalsettings.cpp
+++ b/libs/cglobalsettings.cpp
@@ -28,9 +28,9 @@
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kglobal.h>
-#include <kglobalsettings.h>
#include <QDir>
+#include <QFontDatabase>
#include <map>
@@ -147,7 +147,7 @@ QFont cGlobalSettings::getFont (const QString &name)
return d->fontValues[name];
if (d->defaultFontValues.count (name))
return d->defaultFontValues[name];
- return KGlobalSettings::fixedFont ();
+ return QFontDatabase::systemFont (QFontDatabase::FixedFont);
}
void cGlobalSettings::setDefaultBool (const QString &name, bool val)
@@ -199,14 +199,12 @@ void cGlobalSettings::setDefaultOptions ()
setDefaultBool ("allow-blink", true);
setDefaultBool ("command-echo", true);
setDefaultBool ("show-messages", true);
- setDefaultBool ("word-wrap", true);
setDefaultInt ("indent", 0);
- setDefaultInt ("wrap-pos", 0);
setDefaultInt ("history-size", 1000);
setDefaultInt ("force-redraw", 10);
//Fonts
- QFont f = KGlobalSettings::fixedFont ();
+ QFont f = QFontDatabase::systemFont (QFontDatabase::FixedFont);
setDefaultFont ("console-font", f);
setDefaultFont ("input-font", f);
setDefaultFont ("multi-line-font", f);
@@ -310,7 +308,7 @@ void cGlobalSettings::load ()
entries = g.entryMap ();
for (it = entries.begin(); it != entries.end(); ++it)
setColor (it.key(), g.readEntry (it.key(), getColor(it.key())));
- QFont f = KGlobalSettings::fixedFont ();
+ QFont f = QFontDatabase::systemFont (QFontDatabase::FixedFont);
g = config->group ("Font values");
entries = g.entryMap ();
for (it = entries.begin(); it != entries.end(); ++it)
@@ -354,15 +352,13 @@ void cGlobalSettings::loadOldConfig ()
setBool ("lpmud-style", g.readEntry("LPMud style", false));
setBool ("show-messages", g.readEntry ("Display messages", true));
setBool ("allow-blink", g.readEntry ("Allow blinking", true));
- setBool ("word-wrap", g.readEntry ("Word wrapping", true));
setInt ("indent", g.readEntry ("Indentation", 0));
- setInt ("wrap-pos", g.readEntry ("Wrap position", 0));
setInt ("history-size", g.readEntry ("History size", 1000));
setInt ("force-redraw", g.readEntry ("Force redraw", 10));
//Fonts
g = config->group ("Fonts");
- QFont f = KGlobalSettings::fixedFont ();
+ QFont f = QFontDatabase::systemFont (QFontDatabase::FixedFont);
setFont ("console-font", g.readEntry ("Console font", f));
setFont ("input-font", g.readEntry ("Input line font", f));
setFont ("multi-line-font", g.readEntry ("Multi-line input font", f));
diff --git a/libs/cinputline.cpp b/libs/cinputline.cpp
index e01e169..549b904 100644
--- a/libs/cinputline.cpp
+++ b/libs/cinputline.cpp
@@ -25,8 +25,8 @@
#include <QApplication>
#include <QClipboard>
+#include <QFontDatabase>
#include <QKeyEvent>
-#include <kglobalsettings.h>
class cCompletion : public KCompletion {
public:
@@ -37,7 +37,7 @@ class cCompletion : public KCompletion {
/** Overridden completion function that ensures that short strings do not get \
expanded at all This is because we don't store short commands, and don't want the \
client to auto-complete them to somethign undesirable */
- virtual QString makeCompletion (const QString &string) {
+ virtual QString makeCompletion (const QString &string) override {
if (string.length() < 5) return QString();
return KCompletion::makeCompletion(string);
}
@@ -120,7 +120,7 @@ void cInputLine::initialize ()
setPalette (p);
//change font
- setFont (KGlobalSettings::fixedFont ()); //default system fixed font
+ setFont (QFontDatabase::systemFont (QFontDatabase::FixedFont)); //default system \
fixed font
//set defaults
keeptext = true;
@@ -169,15 +169,15 @@ void cInputLine::setACType (int typeofac)
{
curactype = typeofac;
if (!useac) {
- setCompletionMode (KGlobalSettings::CompletionNone);
+ setCompletionMode (KCompletion::CompletionNone);
return;
}
- KGlobalSettings::Completion comp;
+ KCompletion::CompletionMode comp;
switch (typeofac) {
- case 1: comp = KGlobalSettings::CompletionMan; break;
- case 2: comp = KGlobalSettings::CompletionPopup; break;
+ case 1: comp = KCompletion::CompletionMan; break;
+ case 2: comp = KCompletion::CompletionPopup; break;
case 0:
- default: comp = KGlobalSettings::CompletionAuto; break;
+ default: comp = KCompletion::CompletionAuto; break;
}
setCompletionMode (comp);
}
@@ -426,5 +426,3 @@ void cInputLine::handleTabExpansion ()
setCursorPosition (expandPos + tabWords[tabListPos].length());
}
-#include "cinputline.moc"
-
diff --git a/libs/cinputline.h b/libs/cinputline.h
index 371064f..3e22a09 100644
--- a/libs/cinputline.h
+++ b/libs/cinputline.h
@@ -61,25 +61,25 @@ public slots:
protected slots:
void handleEnter (const QString &text);
protected:
- virtual void eventNothingHandler (QString event, int session);
+ virtual void eventNothingHandler (QString event, int session) override;
virtual QString actionStringHandler (QString action, int, QString &par1,
- const QString &);
+ const QString &) override;
// virtual void paste ();
virtual void paste (const QString &t);
void handleTabExpansion ();
/** event filter - handles TAB expansion */
- virtual bool event (QEvent *e);
+ virtual bool event (QEvent *e) override;
/** keypress event - handles history Up/Down browsing*/
- void keyPressEvent (QKeyEvent *e);
+ void keyPressEvent (QKeyEvent *e) override;
/** mouse-release event - handles middle-click paste */
- void mouseReleaseEvent (QMouseEvent *e);
+ void mouseReleaseEvent (QMouseEvent *e) override;
/** we got focus - restore selection (needed because selection is lost
when switching between connections) */
- void focusInEvent (QFocusEvent *e);
+ void focusInEvent (QFocusEvent *e) override;
/** we lost focus - store selection (needed because selection is lost
when switching between connections)*/
- void focusOutEvent (QFocusEvent *e);
+ void focusOutEvent (QFocusEvent *e) override;
QString getHistory (bool next);
QString menuitem[CMDHISTORYSIZE];
void addHistory (const QString &text);
diff --git a/libs/clist.cpp b/libs/clist.cpp
index 36e1aa8..7d6ccf8 100644
--- a/libs/clist.cpp
+++ b/libs/clist.cpp
@@ -25,11 +25,11 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include "clistgroup.h"
#include "clistmanager.h"
-#include <kicon.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <QAbstractItemModel>
#include <QFont>
+#include <QIcon>
#include <QMimeData>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
@@ -46,7 +46,7 @@ class cListModel : public QAbstractItemModel {
cListModel (cList *l) : QAbstractItemModel(), lst(l) {
}
- virtual QModelIndex index (int row, int column, const QModelIndex &parent = \
QModelIndex()) const + virtual QModelIndex index (int row, int column, const \
QModelIndex &parent = QModelIndex()) const override {
if (!hasIndex(row, column, parent))
return QModelIndex();
@@ -65,7 +65,7 @@ class cListModel : public QAbstractItemModel {
return createIndex (obj->positionInGroup(), 0, (void *) obj);
}
- virtual QModelIndex parent (const QModelIndex &index) const
+ virtual QModelIndex parent (const QModelIndex &index) const override
{
if (!index.isValid()) return QModelIndex();
cListObject *obj = static_cast<cListObject *>(index.internalPointer());
@@ -75,12 +75,12 @@ class cListModel : public QAbstractItemModel {
return createIndex (group->positionInGroup(), 0, (void *) group);
}
- virtual int columnCount (const QModelIndex &) const
+ virtual int columnCount (const QModelIndex &) const override
{
return 1; // we have one column
}
- virtual int rowCount (const QModelIndex &parent = QModelIndex()) const
+ virtual int rowCount (const QModelIndex &parent = QModelIndex()) const override
{
if (parent.column() > 0) return 0; // we only have a single column
@@ -90,7 +90,7 @@ class cListModel : public QAbstractItemModel {
return static_cast<cListGroup *>(obj)->objectCount();
}
- virtual QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole) \
const + virtual QVariant data ( const QModelIndex &index, int role = \
Qt::DisplayRole) const override {
cListObject *obj = index.isValid() ? static_cast<cListObject \
*>(index.internalPointer()) : lst->rootGroup();
@@ -104,7 +104,7 @@ class cListModel : public QAbstractItemModel {
}
if (role == Qt::DecorationRole) {
- return obj->enabled() ? KIcon() : KIcon("dialog-cancel");
+ return obj->enabled() ? QIcon() : QIcon::fromTheme("dialog-cancel");
}
if (role == Qt::FontRole) {
@@ -116,7 +116,7 @@ class cListModel : public QAbstractItemModel {
return QVariant();
}
- virtual Qt::ItemFlags flags (const QModelIndex &index) const
+ virtual Qt::ItemFlags flags (const QModelIndex &index) const override
{
Qt::ItemFlags res = Qt::ItemIsEnabled | Qt::ItemIsSelectable | \
Qt::ItemIsUserCheckable; // anything can be dragged, only groups accept drops
@@ -156,19 +156,19 @@ class cListModel : public QAbstractItemModel {
}
// drag and drop
- Qt::DropActions supportedDropActions () const
+ Qt::DropActions supportedDropActions () const override
{
return Qt::MoveAction;
}
- QStringList mimeTypes () const
+ QStringList mimeTypes () const override
{
QStringList types;
types << "application/kmuddy.object.info";
return types;
}
- QMimeData *mimeData (const QModelIndexList &indexes) const
+ QMimeData *mimeData (const QModelIndexList &indexes) const override
{
QMimeData *mimeData = new QMimeData();
QByteArray encodedData;
@@ -187,7 +187,7 @@ class cListModel : public QAbstractItemModel {
return mimeData;
}
- bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int \
column, const QModelIndex &parent) + bool dropMimeData (const QMimeData *data, \
Qt::DropAction action, int row, int column, const QModelIndex &parent) override {
if (action == Qt::IgnoreAction) return true;
if (!data->hasFormat("application/kmuddy.object.info")) return false;
diff --git a/libs/clisteditor.cpp b/libs/clisteditor.cpp
index 864ab42..ae13b69 100644
--- a/libs/clisteditor.cpp
+++ b/libs/clisteditor.cpp
@@ -26,11 +26,12 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>.
#include <QLabel>
#include <QCheckBox>
+#include <QPushButton>
#include <QVBoxLayout>
-#include <klocale.h>
+
+#include <KLocalizedString>
#include <kmessagebox.h>
#include <knuminput.h>
-#include <kpushbutton.h>
#include <klineedit.h>
struct cListEditor::Private {
@@ -71,8 +72,8 @@ cListEditor::cListEditor (QWidget *parent)
buttonLayout->setSpacing (20);
buttonLayout->setAlignment (Qt::AlignCenter);
- KPushButton *saveButton = new KPushButton (i18n ("&Apply changes"), buttonBar);
- KPushButton *undoButton = new KPushButton (i18n ("&Undo changes"), buttonBar);
+ QPushButton *saveButton = new QPushButton (i18n ("&Apply changes"), buttonBar);
+ QPushButton *undoButton = new QPushButton (i18n ("&Undo changes"), buttonBar);
connect (saveButton, SIGNAL (clicked()), this, SLOT (saveClicked ()));
connect (undoButton, SIGNAL (clicked()), this, SLOT (undoClicked ()));
@@ -311,5 +312,3 @@ void cListEditor::saveDataToObject ()
d->saving = false;
}
-
-#include "clisteditor.moc"
diff --git a/libs/clistgroup.cpp b/libs/clistgroup.cpp
index 3ecf5c6..63a38ce 100644
--- a/libs/clistgroup.cpp
+++ b/libs/clistgroup.cpp
@@ -25,7 +25,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include "clist.h"
#include "clistmanager.h"
-#include <klocale.h>
+#include <KLocalizedString>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
diff --git a/libs/clistgroup.h b/libs/clistgroup.h
index 57ed220..00fc65e 100644
--- a/libs/clistgroup.h
+++ b/libs/clistgroup.h
@@ -40,7 +40,7 @@ public:
void removeObject (cListObject *obj);
void objectChanged (cListObject *obj);
- virtual bool isGroup () { return true; }
+ virtual bool isGroup () override { return true; }
/** Returns the list of objects in this group. */
const std::list<cListObject *> *objectList ();
@@ -71,18 +71,18 @@ protected:
~cListGroup ();
friend class cList;
- virtual void updateVisibleName ();
+ virtual void updateVisibleName () override;
/** Load the group from the XML reader. */
- virtual void load (QXmlStreamReader *reader);
+ virtual void load (QXmlStreamReader *reader) override;
/** Save the group into a XML writer, including all nested groups. */
- virtual void save (QXmlStreamWriter *writer);
+ virtual void save (QXmlStreamWriter *writer) override;
/** regenerate the list of objects stored by priority */
void generatePriorityList ();
/** Recursive traversal of the list, called by cList::traverse */
- virtual cList::TraverseAction traverse (int traversalType);
+ virtual cList::TraverseAction traverse (int traversalType) override;
/** helper function used by generatePriorityList */
static bool compareObjects (cListObject *a, cListObject *b);
diff --git a/libs/clistgroupeditor.cpp b/libs/clistgroupeditor.cpp
index be914c7..4d657fc 100644
--- a/libs/clistgroupeditor.cpp
+++ b/libs/clistgroupeditor.cpp
@@ -50,5 +50,3 @@ void cListGroupEditor::getDataFromGUI (cListObjectData *data)
getDataFromCommonAttribEditor (data);
}
-
-#include "clistgroupeditor.moc"
diff --git a/libs/clistmanager.h b/libs/clistmanager.h
index e914561..dd6c4be 100644
--- a/libs/clistmanager.h
+++ b/libs/clistmanager.h
@@ -63,8 +63,8 @@ class KMUDDY_EXPORT cListManager: public cActionBase {
static cListManager *_self;
void loadList (int sessId, cList *list);
- virtual void eventNothingHandler (QString event, int session);
- virtual void eventStringHandler (QString event, int session, QString &par1, const \
QString &); + virtual void eventNothingHandler (QString event, int session) \
override; + virtual void eventStringHandler (QString event, int session, QString \
&par1, const QString &) override;
struct Private;
Private *d;
diff --git a/libs/clistobject.cpp b/libs/clistobject.cpp
index 15b734b..773f3fe 100644
--- a/libs/clistobject.cpp
+++ b/libs/clistobject.cpp
@@ -373,4 +373,3 @@ void cListObject::save (QXmlStreamWriter *writer)
writer->writeEndElement (); // end the object element
}
-#include "clistobject.moc"
diff --git a/libs/clistviewer.cpp b/libs/clistviewer.cpp
index f45ffe2..3f6ca16 100644
--- a/libs/clistviewer.cpp
+++ b/libs/clistviewer.cpp
@@ -27,12 +27,13 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include "clistgroup.h"
#include <kaction.h>
#include <kactioncollection.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <kinputdialog.h>
#include <kmessagebox.h>
#include <QContextMenuEvent>
#include <QHeaderView>
+#include <QIcon>
#include <QMenu>
#include <QStandardItemModel>
#include <QRegExpValidator>
@@ -62,7 +63,7 @@ cListViewer::cListViewer (QWidget *parent)
// create the actions and popup menus
KAction *actDeleteObj = new KAction (this);
actDeleteObj->setText (i18n ("Delete object"));
- actDeleteObj->setIcon (KIcon ("list-remove"));
+ actDeleteObj->setIcon (QIcon::fromTheme ("list-remove"));
connect (actDeleteObj, SIGNAL (triggered()), this, SLOT (deleteObject()));
d->col->addAction ("DeleteObject", actDeleteObj);
KAction *actDeleteGroup = new KAction (this);
@@ -71,17 +72,17 @@ cListViewer::cListViewer (QWidget *parent)
d->col->addAction ("DeleteGroup", actDeleteGroup);
KAction *actAddSubGroup = new KAction (this);
actAddSubGroup->setText (i18n ("Add subgroup"));
- actAddSubGroup->setIcon (KIcon ("folder-new"));
+ actAddSubGroup->setIcon (QIcon::fromTheme ("folder-new"));
connect (actAddSubGroup, SIGNAL (triggered()), this, SLOT (addGroup()));
d->col->addAction ("AddSubGroup", actAddSubGroup);
KAction *actAddGroup = new KAction (this);
actAddGroup->setText (i18n ("Add group"));
- actAddGroup->setIcon (KIcon ("folder-new"));
+ actAddGroup->setIcon (QIcon::fromTheme ("folder-new"));
connect (actAddGroup, SIGNAL (triggered()), this, SLOT (addGroup()));
d->col->addAction ("AddGroup", actAddGroup);
KAction *actAddObject = new KAction (this);
actAddObject->setText (i18n ("Add object"));
- actAddObject->setIcon (KIcon ("list-add"));
+ actAddObject->setIcon (QIcon::fromTheme ("list-add"));
connect (actAddObject, SIGNAL (triggered()), this, SLOT (addObject()));
d->col->addAction ("AddObject", actAddObject);
@@ -272,5 +273,3 @@ void cListViewer::moveRight ()
selectObject (obj);
}
-
-#include "clistviewer.moc"
diff --git a/libs/cmsp.cpp b/libs/cmsp.cpp
index 00507fd..3293af5 100644
--- a/libs/cmsp.cpp
+++ b/libs/cmsp.cpp
@@ -25,7 +25,7 @@
#include <qdir.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <kstandarddirs.h>
using namespace std;
diff --git a/libs/coutput.cpp b/libs/coutput.cpp
index fae7fca..05a20c1 100644
--- a/libs/coutput.cpp
+++ b/libs/coutput.cpp
@@ -27,13 +27,15 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include "cprofilesettings.h"
#include "ctextchunk.h"
+#include <QScrollBar>
+
#include <kapplication.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <krandom.h>
cOutput::cOutput (int sess, QWidget *parent) : cActionBase ("output", sess)
{
- con = new cConsole (false, parent);
+ con = new cConsole (parent);
setWidget (con);
con->setSession (sess);
@@ -64,6 +66,9 @@ cOutput::cOutput (int sess, QWidget *parent) : cActionBase \
("output", sess) addEventHandler ("message", 50, PT_STRING);
addEventHandler ("user-message", 50, PT_STRING);
addGlobalEventHandler ("global-settings-changed", 50, PT_NOTHING);
+
+ aconsize = 25;
+ con->setScrollTextSize (aconsize);
}
@@ -77,11 +82,11 @@ cOutput::~cOutput ()
removeGlobalEventHandler ("global-settings-changed");
}
-void cOutput::eventNothingHandler (QString event, int session)
+void cOutput::eventNothingHandler (QString event, int /*session*/)
{
if (event == "global-settings-changed") {
cGlobalSettings *gs = cGlobalSettings::self();
- cConsole::setInitialHistorySize (gs->getInt ("history-size"));
+ con->setInitialHistorySize (gs->getInt ("history-size"));
con->setFont (gs->getFont ("console-font"));
setEchoColor (gs->getColor ("color-" + QString::number (gs->getInt \
("echo-color")))); @@ -89,8 +94,6 @@ void cOutput::eventNothingHandler (QString \
event, int session) setEnableEcho (gs->getBool ("command-echo"));
setEnableMessages (gs->getBool ("show-messages"));
con->setEnableBlinking (gs->getBool ("allow-blink"));
- con->setWordWrapping (gs->getBool ("word-wrap"));
- con->setWrapPos (gs->getInt ("wrap-pos"));
con->setIndentation (gs->getInt ("indent"));
con->setRepaintCount (gs->getInt ("force-redraw"));
@@ -145,6 +148,7 @@ void cOutput::setDefaultBkColor (QColor color)
{
bgcolor = color;
con->setDefaultBkColor (color);
+ aconsole->setDefaultBkColor (color);
}
void cOutput::setEchoColor (QColor color)
@@ -246,6 +250,21 @@ void cOutput::makeDecision ()
decisionMessage (s);
}
+void cOutput::aconUp ()
+{
+ //85% is max size
+ if (aconsize > 80) return;
+ aconsize += 5;
+
+ con->setScrollTextSize (aconsize);
+}
+void cOutput::aconDown ()
+{
+ //5% is min size
+ if (aconsize < 10) return;
+ aconsize -= 5;
+
+ con->setScrollTextSize (aconsize);
+}
-#include "coutput.moc"
diff --git a/libs/coutput.h b/libs/coutput.h
index 42faf0d..728880d 100644
--- a/libs/coutput.h
+++ b/libs/coutput.h
@@ -71,14 +71,19 @@ public:
void getAllColors (QColor &_echo, QColor &_system);
void setEnableEcho (bool value);
void setEnableMessages (bool value);
+
+ /** resizing aconsole (CTRL+keys) */
+ void aconUp ();
+ void aconDown ();
+
protected slots:
void dimensionsChanged (int x, int y);
void sendCommand (const QString &command);
void promptCommand (const QString &command);
protected:
- virtual void eventStringHandler (QString event, int, QString &par1, const QString \
&);
- virtual void eventChunkHandler (QString event, int, cTextChunk *chunk);
- virtual void eventNothingHandler (QString event, int session);
+ virtual void eventStringHandler (QString event, int, QString &par1, const QString \
&) override; + virtual void eventChunkHandler (QString event, int, cTextChunk \
*chunk) override; + virtual void eventNothingHandler (QString event, int session) \
override;
/** show commands / messages ? */
bool cmdecho, messages;
@@ -91,6 +96,12 @@ protected:
/** stored cConsole widget */
cConsole *con;
+ /** our auxiliary console */
+ cConsole *aconsole;
+ /** is the auxiliary console visible? */
+ bool aconvisible;
+ /** size of auxiliary console (in percents) */
+ int aconsize;
};
#endif
diff --git a/libs/cplugin.cpp b/libs/cplugin.cpp
index be42363..9c13974 100644
--- a/libs/cplugin.cpp
+++ b/libs/cplugin.cpp
@@ -43,4 +43,3 @@ void cPlugin::sendCommand (int sess, const QString &command)
cActionManager::self()->invokeEvent ("command", sess, command);
}
-#include "cplugin.moc"
diff --git a/libs/cpluginmanager.cpp b/libs/cpluginmanager.cpp
index d6e51da..ef50e4f 100644
--- a/libs/cpluginmanager.cpp
+++ b/libs/cpluginmanager.cpp
@@ -27,9 +27,10 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>.
#include <kdebug.h>
#include <kdialog.h>
-#include <kplugininfo.h>
+#include <KLocalizedString>
+#include <KPluginInfo>
#include <kpluginselector.h>
-#include <ktrader.h>
+#include <KServiceTypeTrader>
//#include <kparts/componentfactory.h>
#include <kparts/plugin.h>
@@ -396,4 +397,3 @@ void cPluginManager::passCommand (int sess, QString &command)
if (dontSend) command = QString();
}
-#include "cpluginmanager.moc"
diff --git a/libs/cprofilemanager.cpp b/libs/cprofilemanager.cpp
index 4164c72..8774f3b 100644
--- a/libs/cprofilemanager.cpp
+++ b/libs/cprofilemanager.cpp
@@ -29,7 +29,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include <QXmlStreamWriter>
#include <kdebug.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <map>
@@ -51,20 +51,20 @@ class cProfileModel : public QAbstractTableModel {
{
}
- virtual int columnCount (const QModelIndex &parent = QModelIndex()) const
+ virtual int columnCount (const QModelIndex &parent = QModelIndex()) const override
{
if (parent.isValid()) return 0; // because Qt docs say so
return 4; // we have 4 columns
}
- virtual int rowCount (const QModelIndex &parent = QModelIndex()) const
+ virtual int rowCount (const QModelIndex &parent = QModelIndex()) const override
{
if (parent.isValid()) return 0; // because Qt docs say so
return mgr->profileList().size();
}
virtual QVariant headerData ( int section, Qt::Orientation /*orientation*/,
- int role = Qt::DisplayRole ) const
+ int role = Qt::DisplayRole ) const override
{
if (role != Qt::DisplayRole) return QVariant();
switch (section) {
@@ -76,7 +76,7 @@ class cProfileModel : public QAbstractTableModel {
}
}
- virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) \
const + virtual QVariant data ( const QModelIndex & index, int role = \
Qt::DisplayRole ) const override {
// display role only
if (role != Qt::DisplayRole) return QVariant();
diff --git a/libs/cprompt.cpp b/libs/cprompt.cpp
index 3b9a08e..a5f8754 100644
--- a/libs/cprompt.cpp
+++ b/libs/cprompt.cpp
@@ -57,5 +57,3 @@ void cPrompt::updatePrompt(const QString &text)
setText (text);
}
-#include "cprompt.moc"
-
diff --git a/libs/cscripteditor.cpp b/libs/cscripteditor.cpp
index 1f36324..7cefc6d 100644
--- a/libs/cscripteditor.cpp
+++ b/libs/cscripteditor.cpp
@@ -83,5 +83,3 @@ void cScriptEditor::checkScript ()
d->scriptError->setText (err);
}
-
-#include "cscripteditor.moc"
diff --git a/libs/cscripteval.cpp b/libs/cscripteval.cpp
index 60c5e2e..f0aeedd 100644
--- a/libs/cscripteval.cpp
+++ b/libs/cscripteval.cpp
@@ -111,4 +111,3 @@ bool cScriptEval::event (QEvent *e)
return true;
}
-#include "cscripteval.moc"
diff --git a/libs/csoundplayer.cpp b/libs/csoundplayer.cpp
index e0a3665..a5ac7b0 100644
--- a/libs/csoundplayer.cpp
+++ b/libs/csoundplayer.cpp
@@ -17,20 +17,12 @@
#include "csoundplayer.h"
-#include <Phonon/MediaObject>
-#include <Phonon/Path>
-#include <Phonon/AudioOutput>
-#include <Phonon/Global>
-
struct cSoundPlayer::Private {
- Phonon::MediaObject *media;
- Phonon::AudioOutput *output;
+ QMediaPlayer player;
bool isWave;
bool nosound;
- bool playing;
-
QString fName;
int repeatCount, priority, volume;
QString newFName;
@@ -42,11 +34,8 @@ cSoundPlayer::cSoundPlayer (bool isWAVE)
{
d = new Private;
- d->media = 0;
d->isWave = isWAVE;
d->nosound = false;
-
- d->playing = false;
}
cSoundPlayer::~cSoundPlayer()
@@ -57,17 +46,12 @@ cSoundPlayer::~cSoundPlayer()
void cSoundPlayer::init ()
{
- if (d->media) return;
- d->media = new Phonon::MediaObject (this);
- d->output = new Phonon::AudioOutput (Phonon::MusicCategory, this);
- createPath (d->media, d->output);
- connect (d->media, SIGNAL (finished()), this, SLOT (finished()));
- connect (d->media, SIGNAL (stateChanged(Phonon::State, Phonon::State)), this, SLOT \
(stateChanged(Phonon::State))); + connect (&d->player, SIGNAL \
(stateChanged(QMediaPlayer::State)), this, SLOT (stateChanged(QMediaPlayer::State))); \
}
bool cSoundPlayer::isPlaying ()
{
- return d->playing;
+ return (d->player.state() == QMediaPlayer::PlayingState);
}
int cSoundPlayer::curPriority ()
@@ -116,7 +100,6 @@ void cSoundPlayer::play ()
// stop existing sound, if any
stop ();
- d->playing = false;
//apply new parameters
d->fName = d->newFName;
@@ -127,20 +110,15 @@ void cSoundPlayer::play ()
// Intialise the play object, if needed
init ();
- // assign the source
- d->media->setCurrentSource (d->fName);
- // set volume
- d->output->setVolume ((qreal) d->volume / 100);
- // and play
- d->media->play ();
+ d->player.setMedia (QUrl::fromLocalFile (d->fName));
+ d->player.setVolume (d->volume);
+ d->player.play ();
}
void cSoundPlayer::stop ()
{
if (d->nosound) return;
- if (!d->media) return;
- d->media->stop();
- d->playing = false;
+ d->player.stop();
}
void cSoundPlayer::forceUpdateParams ()
@@ -155,24 +133,23 @@ void cSoundPlayer::disableSound ()
d->nosound = true;
}
-void cSoundPlayer::stateChanged (Phonon::State newState)
+void cSoundPlayer::stateChanged (QMediaPlayer::State newState)
{
- d->playing = (newState == Phonon::PlayingState);
+ if ((newState == QMediaPlayer::StoppedState) && (d->player.mediaStatus() == \
QMediaPlayer::EndOfMedia)) + finished();
+
// TODO error reporting
}
void cSoundPlayer::finished ()
{
- d->playing = false;
-
if (d->repeatCount != -1) //-1 means infinite playing
d->repeatCount--; //decrease repeat count
if (d->repeatCount != 0) {
// we need to play again - so play again
- d->media->setCurrentSource (d->fName);
- d->media->play ();
+ d->player.setMedia (QUrl::fromLocalFile (d->fName));
+ d->player.setVolume (d->volume);
+ d->player.play ();
}
}
-#include "csoundplayer.moc"
-
diff --git a/libs/csoundplayer.h b/libs/csoundplayer.h
index 4228bb3..3159fc5 100644
--- a/libs/csoundplayer.h
+++ b/libs/csoundplayer.h
@@ -22,7 +22,7 @@
#include <kmuddy_export.h>
#include <qobject.h>
-#include <Phonon/Global>
+#include <QMediaPlayer>
/**
Plays sound via Phonon.
@@ -62,10 +62,10 @@ public:
void forceUpdateParams ();
void disableSound ();
protected slots:
- void stateChanged (Phonon::State newState);
- void finished ();
+ void stateChanged (QMediaPlayer::State newState);
protected:
void init ();
+ void finished ();
struct Private;
Private *d;
diff --git a/libs/cstatus.cpp b/libs/cstatus.cpp
index adc7865..4047e64 100644
--- a/libs/cstatus.cpp
+++ b/libs/cstatus.cpp
@@ -19,7 +19,7 @@
#include "cstatus.h"
#include <QTextStream>
-#include <klocale.h>
+#include <KLocalizedString>
#include "cprofilesettings.h"
@@ -258,5 +258,3 @@ void cStatus::timer1Tick ()
sb->changeItem (" " + i18n ("idle") + ss, ID_IDLE);
}
-#include "cstatus.moc"
-
diff --git a/libs/cstatus.h b/libs/cstatus.h
index c8e71c4..85aaf99 100644
--- a/libs/cstatus.h
+++ b/libs/cstatus.h
@@ -46,10 +46,10 @@ public:
KStatusBar *statusBar() { return sb; };
protected:
- virtual void eventNothingHandler (QString event, int session);
+ virtual void eventNothingHandler (QString event, int session) override;
virtual void eventStringHandler (QString event, int session,
- QString &par1, const QString &);
- virtual void eventIntHandler (QString event, int session, int par1, int par2);
+ QString &par1, const QString &) override;
+ virtual void eventIntHandler (QString event, int session, int par1, int par2) \
override;
void dimensionsChanged (int x, int y);
void timerStart ();
diff --git a/libs/ctextchunk.cpp b/libs/ctextchunk.cpp
index 5997494..638221e 100644
--- a/libs/ctextchunk.cpp
+++ b/libs/ctextchunk.cpp
@@ -30,13 +30,14 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include <qpainter.h>
#include <qregexp.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <stdlib.h>
QColor chunkLink::linkColor = Qt::blue;
/** state variables needed to paint a row */
+/*
struct paintStatus {
int length, selstart, sellen;
@@ -51,6 +52,7 @@ struct paintStatus {
QColor paintColor, fillColor;
QColor defbkcolor;
};
+*/
cTextChunk::cTextChunk (cConsole *_console)
{
@@ -69,7 +71,7 @@ void cTextChunk::init (cConsole *_console)
{
startattr.startpos = 0;
startattr.attrib = 0;
- pstatus = new paintStatus;
+// pstatus = new paintStatus;
console = _console;
//update the timestamp
timestamp = QDateTime::currentDateTime();
@@ -82,7 +84,7 @@ cTextChunk::~cTextChunk ()
for (it = _entries.begin(); it != _entries.end(); ++it)
delete *it;
_entries.clear();
- delete pstatus;
+// delete pstatus;
}
void cTextChunk::appendEntry (chunkItem *entry)
@@ -610,6 +612,8 @@ cTextChunk *cTextChunk::duplicate ()
return chunk;
}
+// TODO - we don't need this any more
+/*
void cTextChunk::paint (int length, int selstart, int sellen,
int charWidth, int charHeight,
QPainter *painter, QPainter *blinkpainter)
@@ -664,6 +668,7 @@ void cTextChunk::paint (int length, int selstart, int sellen,
}
}
}
+*/
QString cTextChunk::toText ()
{
@@ -675,7 +680,6 @@ QString cTextChunk::toText ()
list<chunkItem *>::iterator it;
for (it = _entries.begin(); it != _entries.end(); ++it)
s += (*it)->toText();
- s += "\n";
return s;
}
@@ -696,7 +700,6 @@ QString cTextChunk::toAnsi (cANSIParser *ap)
list<chunkItem *>::iterator it;
for (it = _entries.begin(); it != _entries.end(); ++it)
s += (*it)->toAnsi (ap);
- s += "\n";
return s;
}
@@ -716,9 +719,6 @@ QString cTextChunk::toHTML ()
for (it = _entries.begin(); it != _entries.end(); ++it)
s += (*it)->toHTML (suffix);
s += suffix;
- //we use <pre>, hence we don't need the <br> tag
- //s += "<br>";
- s += "\n";
return s;
}
@@ -949,6 +949,7 @@ void chunkLink::parseMenu ()
}
}
+/*
void chunkItem::paintText (const QString &text, QPainter *painter, QFont font,
QColor fg, QColor bg, paintStatus *ps)
{
@@ -1113,6 +1114,7 @@ void chunkLink::paint (QPainter *painter, paintStatus *ps)
//okay, paint the text!
paintText (_text, painter, font, paintColor, fillColor, ps);
}
+*/
QString chunkFg::constructAnsi (QColor color, cANSIParser *ap)
{
@@ -1262,7 +1264,7 @@ QString chunkLink::toAnsi (cANSIParser *ap)
QString chunkFg::constructHTML (QColor color, QString &suffix)
{
suffix = "</font>" + suffix;
- return "<font color=\"" + color.name() + "\">";
+ return "<font style=\"color: " + color.name() + "\">";
}
QString chunkBg::constructHTML (QColor, QString &)
@@ -1289,7 +1291,7 @@ QString chunkLink::toHTML (QString &)
}
else
{
- return "<a href=\"" + _target + "\">" + _text + "</a>";
+ return "<a style=\"color: " + linkColor.name() + "\" href=\"" + _target + "\">" \
+ _text + "</a>"; }
}
diff --git a/libs/ctextchunk.h b/libs/ctextchunk.h
index a9b8fb0..c866690 100644
--- a/libs/ctextchunk.h
+++ b/libs/ctextchunk.h
@@ -38,7 +38,7 @@ class cConsole;
class QPainter;
-struct paintStatus;
+// struct paintStatus;
/** one item in a cTextChunk chunk - abstract base class */
@@ -56,7 +56,7 @@ class KMUDDY_EXPORT chunkItem {
virtual void replace (int, int, const QString &) {};
//painting the text...
- virtual void paint (QPainter *painter, paintStatus *ps) = 0;
+// virtual void paint (QPainter *painter, paintStatus *ps) = 0;
//output to transcript...
/** plain-text output */
@@ -66,8 +66,7 @@ class KMUDDY_EXPORT chunkItem {
/** output to HTML, suffix can be used to provide closing tags if needed */
virtual QString toHTML (QString &) { return QString(); };
protected:
- void paintText (const QString &text, QPainter *painter, QFont font, QColor fg, \
QColor bg,
- paintStatus *ps);
+// void paintText (const QString &text, QPainter *painter, QFont font, QColor fg, \
QColor bg, paintStatus *ps); int startpos;
};
@@ -147,9 +146,7 @@ public:
cTextChunk *duplicate ();
//painting...
- void paint (int length, int selstart, int sellen,
- int charWidth, int charHeight,
- QPainter *painter, QPainter *blinkpainter = 0);
+// void paint (int length, int selstart, int sellen, int charWidth, int charHeight, \
QPainter *painter, QPainter *blinkpainter = 0);
//output to transcript...
/** plain-text output */
@@ -180,7 +177,7 @@ protected:
QDateTime timestamp;
/** paint status used by paint() */
- paintStatus *pstatus;
+// paintStatus *pstatus;
};
@@ -193,23 +190,23 @@ class KMUDDY_EXPORT chunkText : public chunkItem {
const QString &text() { return _text; }
void setText (const QString &t) { _text = t; }
- virtual int length() { return _text.length(); }
+ virtual int length() override { return _text.length(); }
//pos is index of last index that will remain in this item
- virtual chunkItem *split (int pos);
- virtual chunkItem *duplicate();
- virtual void trimLeft ();
- virtual void replace (int pos, int len, const QString &newtext);
+ virtual chunkItem *split (int pos) override;
+ virtual chunkItem *duplicate() override;
+ virtual void trimLeft () override;
+ virtual void replace (int pos, int len, const QString &newtext) override;
//painting
- virtual void paint (QPainter *painter, paintStatus *ps);
+// virtual void paint (QPainter *painter, paintStatus *ps) override;
//output to transcript...
/** plain-text output */
- virtual QString toText () { return _text; };
+ virtual QString toText () override { return _text; };
/** output to plain-text with ANSI sequences */
- virtual QString toAnsi (cANSIParser *) {return _text; };
+ virtual QString toAnsi (cANSIParser *) override {return _text; };
/** output to HTML, suffix can be used to provide closing tags if needed */
- virtual QString toHTML (QString &);
+ virtual QString toHTML (QString &) override;
protected:
QString _text;
};
@@ -217,21 +214,21 @@ class KMUDDY_EXPORT chunkText : public chunkItem {
#define CHUNK_FG 2
class KMUDDY_EXPORT chunkFg : public chunkItem {
public:
- virtual int type() { return CHUNK_FG; };
+ virtual int type() override { return CHUNK_FG; };
QColor fg() { return _fg; }
void setFg (QColor fgc) { _fg = fgc; }
- virtual int length() { return 0; }
- virtual chunkItem *duplicate();
+ virtual int length() override { return 0; }
+ virtual chunkItem *duplicate() override;
//painting
- virtual void paint (QPainter *painter, paintStatus *ps);
+// virtual void paint (QPainter *painter, paintStatus *ps) override;
//output to transcript...
/** output to plain-text with ANSI sequences */
- virtual QString toAnsi (cANSIParser *ap);
+ virtual QString toAnsi (cANSIParser *ap) override;
/** output to HTML, suffix can be used to provide closing tags if needed */
- virtual QString toHTML (QString &suffix);
+ virtual QString toHTML (QString &suffix) override;
static QString constructAnsi (QColor color, cANSIParser *ap);
static QString constructHTML (QColor color, QString &suffix);
@@ -242,21 +239,21 @@ class KMUDDY_EXPORT chunkFg : public chunkItem {
#define CHUNK_BG 3
class KMUDDY_EXPORT chunkBg : public chunkItem {
public:
- virtual int type() { return CHUNK_BG; };
+ virtual int type() override { return CHUNK_BG; };
QColor bg() { return _bg; }
void setBg (QColor bgc) { _bg = bgc; }
- virtual int length() { return 0; }
- virtual chunkItem *duplicate();
+ virtual int length() override { return 0; }
+ virtual chunkItem *duplicate() override;
//painting
- virtual void paint (QPainter *painter, paintStatus *ps);
+// virtual void paint (QPainter *painter, paintStatus *ps) override;
//output to transcript...
/** output to plain-text with ANSI sequences */
- virtual QString toAnsi (cANSIParser *ap);
+ virtual QString toAnsi (cANSIParser *ap) override;
/** output to HTML, suffix can be used to provide closing tags if needed */
- virtual QString toHTML (QString &suffix);
+ virtual QString toHTML (QString &suffix) override;
static QString constructAnsi (QColor color, cANSIParser *ap);
static QString constructHTML (QColor color, QString &suffix);
@@ -277,18 +274,18 @@ class KMUDDY_EXPORT chunkBg : public chunkItem {
#define CHUNK_ATTRIB 4
class KMUDDY_EXPORT chunkAttrib : public chunkItem {
public:
- virtual int type() { return CHUNK_ATTRIB; };
+ virtual int type() override { return CHUNK_ATTRIB; };
int attrib() { return _attrib; }
void setAttrib (int a) { _attrib = a; }
- virtual int length() { return 0; }
- virtual chunkItem *duplicate();
+ virtual int length() override { return 0; }
+ virtual chunkItem *duplicate() override;
//painting
- virtual void paint (QPainter *painter, paintStatus *ps);
+// virtual void paint (QPainter *painter, paintStatus *ps) override;
//output to transcript...
/** output to plain-text with ANSI sequences */
- virtual QString toAnsi (cANSIParser *);
+ virtual QString toAnsi (cANSIParser *) override;
//no HTML output here - we cannot handle closing tags properly without too much \
hassle
@@ -305,7 +302,7 @@ struct menuItem {
#define CHUNK_LINK 5
class KMUDDY_EXPORT chunkLink : public chunkItem {
public:
- virtual int type() { return CHUNK_LINK; };
+ virtual int type() override { return CHUNK_LINK; };
QString name() { return _name; }
void setName (const QString &n) { _name = n; }
@@ -326,21 +323,21 @@ class KMUDDY_EXPORT chunkLink : public chunkItem {
/** parse menu information */
void parseMenu ();
- virtual int length() { return _text.length(); }
- virtual chunkItem *split (int pos);
- virtual chunkItem *duplicate ();
- virtual void trimLeft ();
- virtual void replace (int pos, int len, const QString &newtext);
+ virtual int length() override { return _text.length(); }
+ virtual chunkItem *split (int pos) override;
+ virtual chunkItem *duplicate () override;
+ virtual void trimLeft () override;
+ virtual void replace (int pos, int len, const QString &newtext) override;
const list<menuItem> &menu() { return _menu; };
//painting
- virtual void paint (QPainter *painter, paintStatus *ps);
+// virtual void paint (QPainter *painter, paintStatus *ps) override;
//output to transcript...
/** output to plain-text with ANSI sequences */
- virtual QString toAnsi (cANSIParser *ap);
+ virtual QString toAnsi (cANSIParser *ap) override;
/** output to HTML, suffix can be used to provide closing tags if needed */
- virtual QString toHTML (QString &suffix);
+ virtual QString toHTML (QString &suffix) override;
protected:
QString _name, _target, _text, _hint;
bool _iscommand, _toprompt, _ismenu;
diff --git a/libs/cvariablelist.cpp b/libs/cvariablelist.cpp
index 55f7bd1..590a125 100644
--- a/libs/cvariablelist.cpp
+++ b/libs/cvariablelist.cpp
@@ -23,7 +23,7 @@
#include "cvariable.h"
#include <kdebug.h>
-#include <klocale.h>
+#include <KLocalizedString>
#include <QDir>
#include <QFile>
diff --git a/libs/kmuddy_export.h b/libs/kmuddy_export.h
index 6ca1353..fbb25f7 100644
--- a/libs/kmuddy_export.h
+++ b/libs/kmuddy_export.h
@@ -3,16 +3,15 @@
#ifndef KMUDDY_EXPORT_H
#define KMUDDY_EXPORT_H
-/* needed for KDE_EXPORT and KDE_IMPORT macros */
-#include <kdemacros.h>
+#include <QtGlobal>
#ifndef KMUDDY_EXPORT
# if defined(MAKE_KMUDDYCORE_LIB)
/* We are building this library */
-# define KMUDDY_EXPORT KDE_EXPORT
+# define KMUDDY_EXPORT Q_DECL_EXPORT
# else
/* We are using this library */
-# define KMUDDY_EXPORT KDE_IMPORT
+# define KMUDDY_EXPORT Q_DECL_IMPORT
# endif
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic