Commit cc7f1910 authored by Tomas Mecir's avatar Tomas Mecir

Fix indentation. Fix some global settings dialog widgets. Some more porting away from kde4support.

parent 2e3dd02f
......@@ -60,7 +60,7 @@ void cWindowList::eventNothingHandler (QString event, int)
if (event == "global-settings-changed") {
cGlobalSettings *gs = cGlobalSettings::self();
adjustFonts (gs->getFont ("console-font"));
applySettings (gs->getBool ("allow-blink"), gs->getInt ("indent"), gs->getBool ("force-redraw"));
applySettings (gs->getBool ("allow-blink"), gs->getInt ("indent"));
}
}
......@@ -234,7 +234,7 @@ void cWindowList::adjustFonts(QFont font)
}
}
void cWindowList::applySettings (bool allowblinking, int indentvalue, int forceredraw)
void cWindowList::applySettings (bool allowblinking, int indentvalue)
{
map<QString, dlgOutputWindow *>::iterator it;
for (it = windows.begin(); it != windows.end(); ++it)
......@@ -242,7 +242,6 @@ void cWindowList::applySettings (bool allowblinking, int indentvalue, int forcer
cConsole *console = it->second->console();
console->setEnableBlinking (allowblinking);
console->setIndentation (indentvalue);
console->setRepaintCount (forceredraw);
}
}
......
......@@ -67,7 +67,7 @@ public:
void save ();
void adjustFonts(QFont font);
void applySettings (bool allowblinking, int indentvalue, int forceredraw);
void applySettings (bool allowblinking, int indentvalue);
protected:
void load ();
......
......@@ -34,6 +34,7 @@
#include <QIcon>
#include <QLabel>
#include <QPushButton>
#include <QSpinBox>
#include <kapplication.h>
#include <kcolorbutton.h>
......@@ -42,9 +43,26 @@
#include <kshortcutsdialog.h>
#include <klineedit.h>
#include <klocale.h>
#include <knuminput.h>
#include <kstandarddirs.h>
QSpinBox *setupSpinbox (QGridLayout *layout, int row, int firstcol, const QString &label, int min, int max, const QString &specialVal, const QString &whatsThis)
{
QSpinBox *box = new QSpinBox;
box->setMinimum (min);
box->setMaximum (max);
box->setSpecialValueText (specialVal);
box->setWhatsThis( whatsThis);
QLabel *clabel = new QLabel (label);
clabel->setAlignment (Qt::AlignLeft | Qt::AlignVCenter);
clabel->setBuddy (box);
layout->addWidget (clabel, row, firstcol);
layout->addWidget (box, row, firstcol + 1);
return box;
}
dlgAppSettings::dlgAppSettings (QWidget *parent) : KPageDialog (parent)
{
cDialogList::self()->addDialog ("app-prefs", this);
......@@ -164,6 +182,7 @@ dlgAppSettings::dlgAppSettings (QWidget *parent) : KPageDialog (parent)
//page 2
QVBoxLayout *outlayout = new QVBoxLayout (frmoutputarea);
//colors
QWidget *wcolors = new QWidget (frmoutputarea);
QGridLayout *wincolorlayout = new QGridLayout (wcolors);
......@@ -202,79 +221,45 @@ dlgAppSettings::dlgAppSettings (QWidget *parent) : KPageDialog (parent)
wincolorlayout->setRowStretch (4, 10);
wincolorlayout->setColumnStretch (2, 3);
KHBox *outputs = new KHBox (frmoutputarea);
//output1 and output2 come in reversed order, because I'm too lazy to rewrite all the stuff ;)
KVBox *output2 = new KVBox (outputs);
KVBox *output1 = new KVBox (outputs);
outputs->setSpacing (10);
output1->setSpacing (10);
output2->setSpacing (10);
QFrame *outputs = new QFrame (frmoutputarea);
QFrame *output1 = new QFrame (outputs);
QFrame *output2 = new QFrame (outputs);
QHBoxLayout *outputsLayout = new QHBoxLayout (outputs);
outputsLayout->setSpacing (10);
QGridLayout *output1Layout = new QGridLayout (output1);
QVBoxLayout *output2Layout = new QVBoxLayout (output2);
output1Layout->setSpacing (10);
output2Layout->setSpacing (10);
outputsLayout->addWidget (output1);
outputsLayout->addWidget (output2);
//indentation
edindent = setupSpinbox (output1Layout, 0, 0, i18n ("&Indentation"), 0, 10, i18n ("None"),
i18n ("When a line is too long, part of it will be moved to the next line. Indentation says how many spaces will be "
"put to the beginning of the continued line."));
//history size
edhistory = setupSpinbox (output1Layout, 2, 0, i18n ("&History buffer size"), 100, 10000, QString(), i18n ("Size of output scroll-back buffer. "
"Please note that this setting will only affect new connections, existing ones will keep their history setting."));
edhistory->setSingleStep (100);
edhistory->setSuffix (" " + i18n ("lines"));
//cmd echo and system messages
chkcmdecho = new QCheckBox (i18n ("Enable co&mmand echo"), output1);
chkcmdecho = new QCheckBox (i18n ("Enable co&mmand echo"), output2);
chkcmdecho->setWhatsThis( i18n ("Enables displaying of commands in the "
"console.<p><b>Please note:</b> This will also disable command echo "
"in session transcript."));
chkmessages = new QCheckBox (i18n ("Enable s&ystem messages"), output1);
chkmessages = new QCheckBox (i18n ("Enable s&ystem messages"), output2);
chkmessages->setWhatsThis( i18n ("Enables displaying of system messages "
"in the console."));
//blinking
chkblinking = new QCheckBox (i18n ("Enable b&linking"), output1);
chkblinking->setWhatsThis( i18n ("Enables support for blinking. "));
chkblinking = new QCheckBox (i18n ("Enable b&linking"), output2);
chkblinking->setWhatsThis( i18n ("Enables support for blinking. Currently not supported."));
chkblinking->setEnabled (false); // currently not supported
//indentation
edindent = new KIntNumInput (output2);
edindent->setLabel (i18n ("&Indentation"),
Qt::AlignLeft | Qt::AlignVCenter);
edindent->setMinimum (0);
edindent->setMaximum (10);
edindent->setSpecialValueText (i18n ("None"));
//edindent shouldn't be too wide
edindent->setMaximumSize (edindent->minimumSizeHint ());
edindent->setWhatsThis( i18n ("When a line is too long, part of it will "
"be moved to the next line. Indentation says how many spaces will be "
"put to the beginning of the continued line."));
//wrap at
edwrappos = new KIntNumInput (output2);
edwrappos->setLabel (i18n ("W&rap at position"),
Qt::AlignLeft | Qt::AlignVCenter);
edwrappos->setMinimum (0);
edwrappos->setMaximum (250);
edwrappos->setSpecialValueText (i18n ("As needed"));
//edwrappos shouldn't be too wide
edwrappos->setMaximumSize (edwrappos->minimumSizeHint ());
edwrappos->setWhatsThis( i18n ("Wrap at a fixed position, or at the rightmost position, "
"if no value is given."));
//history size
edhistory = new KIntNumInput (output2);
edhistory->setLabel (i18n ("&History buffer size"),
Qt::AlignLeft | Qt::AlignVCenter);
edhistory->setRange (100, 10000, 100);
edhistory->setSliderEnabled (false);
edhistory->setSuffix (" " + i18n ("lines"));
//edhistory shouldn't be too wide too
edhistory->setMaximumSize (edhistory->minimumSizeHint ());
edhistory->setWhatsThis( i18n ("Size of output scroll-back buffer. "
"Please note that this setting will only affect new connections, "
"existing ones will keep their history setting."));
//force redraw
edforceredraw = new KIntNumInput (output2);
edforceredraw->setLabel (i18n ("&Forced redraw after"),
Qt::AlignLeft | Qt::AlignVCenter);
edforceredraw->setRange (0, 20, 1);
edforceredraw->setSliderEnabled (false);
edforceredraw->setSuffix (" " + i18n ("lines"));
edforceredraw->setSpecialValueText (i18n ("Never"));
//edhistory shouldn't be too wide too
edforceredraw->setMaximumSize (edforceredraw->minimumSizeHint ());
edforceredraw->setWhatsThis( i18n ("Forced redraw after adding a given amount "
"of lines. Setting this to a low number may prevent some displaying problems, at a cost "
"of higher CPU usage. Setting it to Never will disable the feature, redraw will "
"only occur when needed."));
output2Layout->addWidget (chkcmdecho);
output2Layout->addWidget (chkmessages);
output2Layout->addWidget (chkblinking);
//add widgets to main layout
outlayout->setSpacing (10);
......@@ -636,16 +621,6 @@ int dlgAppSettings::history ()
return edhistory->value ();
}
int dlgAppSettings::forceRedraw ()
{
return edforceredraw->value ();
}
void dlgAppSettings::setForceRedraw (int value)
{
edforceredraw->setValue (value);
}
bool dlgAppSettings::enableBlinking ()
{
return chkblinking->isChecked ();
......@@ -1057,7 +1032,6 @@ void dlgAppSettings::getSettingsFromDialog ()
gs->setBool ("show-messages", messages ());
gs->setInt ("indent", indentation ());
gs->setInt ("history-size", history ());
gs->setInt ("force-redraw", forceRedraw ());
//Fonts
gs->setFont ("console-font", font1 ());
......@@ -1136,7 +1110,6 @@ void dlgAppSettings::putSettingsToDialog ()
setMessages (gs->getBool ("show-messages"));
setIndentation (gs->getInt ("indent"));
setHistory (gs->getInt ("history-size"));
setForceRedraw (gs->getInt ("force-redraw"));
//Fonts
setFont1 (gs->getFont ("console-font"));
......
......@@ -26,9 +26,9 @@
class QLabel;
class QComboBox;
class QCheckBox;
class QSpinBox;
class KColorButton;
class KLineEdit;
class KIntNumInput;
class KShortcutsEditor;
class cDirList;
......@@ -82,8 +82,6 @@ public:
int indentation ();
void setHistory (int value);
int history ();
int forceRedraw ();
void setForceRedraw (int value);
//Font
void setFont1 (QFont f);
......@@ -162,8 +160,7 @@ protected:
QComboBox *combo[4];
QCheckBox *chkcmdecho, *chkmessages;
QCheckBox *chkblinking;
QCheckBox *chkwrap;
KIntNumInput *edindent, *edhistory, *edwrappos, *edforceredraw;
QSpinBox *edindent, *edhistory;
//Font
QLabel *fonted1, *fonted2, *fonted3;
QFont font[3];
......
......@@ -120,6 +120,7 @@ class cConsole::Private {
QColor bgcolor;
QFont font;
int sess;
int indentChars;
double charWidth, charHeight;
bool wantNewLine;
bool atBottom;
......@@ -137,6 +138,7 @@ cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) {
d->wantNewLine = false;
d->atBottom = true;
d->historySize = 1000;
d->indentChars = 0;
setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
......@@ -275,7 +277,7 @@ void cConsole::sliderChanged (int val)
setScrollTextVisible (vis);
}
void cConsole::sceneChanged (const QList<QRectF> &region)
void cConsole::sceneChanged (const QList<QRectF> &)
{
// move back to the bottom if we were
if (!d->atBottom) return;
......@@ -290,7 +292,8 @@ void cConsole::setScrollTextSize (int aconsize)
}
void cConsole::setIndentation (int val) {
// TODO
d->indentChars = val;
}
void cConsole::setEnableBlinking (bool value) {
......@@ -306,10 +309,6 @@ int cConsole::curCols() {
return width() / d->charWidth;
}
void cConsole::setRepaintCount (int val) {
// TODO
}
void cConsole::forceEmitSize () {
emit dimensionsChanged (curCols(), curRows());
}
......@@ -384,6 +383,9 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
d->wantNewLine = false;
QTextBlockFormat bformat = cursor.blockFormat();
bformat.setLineHeight (2, QTextBlockFormat::LineDistanceHeight);
double px = d->indentChars * d->charWidth; // 0 if no indentation is to happen
bformat.setLeftMargin (px);
bformat.setTextIndent (-1 * px);
cursor.setBlockFormat (bformat);
}
......@@ -531,6 +533,7 @@ void cConsole::linkActivated (const QString &link)
}
/*
void cConsole::activateLink (chunkLink *link, const QPoint &point)
{
......@@ -596,10 +599,3 @@ void cConsole::linkMenuItemHandler (QAction *item)
}
*/
/*
TODO SIGNALS - these must be emitted
void sendCommand (const QString &command); -- in activateLink
void promptCommand (const QString &command); -- in activateLink
*/
......@@ -67,9 +67,6 @@ public:
/** Size of the secondary console shown while scrolling */
void setScrollTextSize (int aconsize);
/** number of lines until a forced repaint */
void setRepaintCount (int val);
/** forces amission of dimensionsChanged signal; used by toolbar hiding
functions, where this fails for unknown reasons */
void forceEmitSize ();
......
......@@ -94,7 +94,6 @@ void cOutput::eventNothingHandler (QString event, int /*session*/)
setEnableMessages (gs->getBool ("show-messages"));
con->setEnableBlinking (gs->getBool ("allow-blink"));
con->setIndentation (gs->getInt ("indent"));
con->setRepaintCount (gs->getInt ("force-redraw"));
//changing font often causes view to move - move to the very bottom
con->verticalScrollBar()->setValue (con->verticalScrollBar()->maximum());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment