aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-21 13:03:16 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-21 13:03:16 (GMT)
commit16c0e4a1be8a53966603b09f307d38b3e74250fa (patch)
tree4fe62547eec8525ea2888ca5c683dbec44a02209
parente81f4bd908ed4f60dd9eb0893e761d230d9e9c2a (diff)
use integrated status bar, need to add API to hide it
-rw-r--r--kwrite/kwrite.cpp130
-rw-r--r--kwrite/kwrite.h27
2 files changed, 6 insertions, 151 deletions
diff --git a/kwrite/kwrite.cpp b/kwrite/kwrite.cpp
index a2d5776..47b6e92 100644
--- a/kwrite/kwrite.cpp
+++ b/kwrite/kwrite.cpp
@@ -53,7 +53,6 @@
#include <QMimeData>
#include <QApplication>
#include <QLabel>
-#include <QStatusBar>
#include <QDragEnterEvent>
QList<KTextEditor::Document*> KWrite::docList;
@@ -84,19 +83,12 @@ KWrite::KWrite (KTextEditor::Document *doc)
setCentralWidget(m_view);
setupActions();
- setupStatusBar();
// signals for the statusbar
- connect(m_view, SIGNAL(cursorPositionChanged(KTextEditor::View*,KTextEditor::Cursor)), this, SLOT(cursorPositionChanged(KTextEditor::View*)));
- connect(m_view, SIGNAL(viewModeChanged(KTextEditor::View*)), this, SLOT(viewModeChanged(KTextEditor::View*)));
- connect(m_view, SIGNAL(selectionChanged(KTextEditor::View*)), this, SLOT(selectionChanged(KTextEditor::View*)));
- connect(m_view, SIGNAL(informationMessage(KTextEditor::View*,QString)), this, SLOT(informationMessage(KTextEditor::View*,QString)));
- connect(m_view->document(), SIGNAL(modifiedChanged(KTextEditor::Document*)), this, SLOT(modifiedChanged()));
- connect(m_view->document(), SIGNAL(modifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)), this, SLOT(modifiedChanged()) );
+ connect(m_view->document(), SIGNAL(modifiedChanged(KTextEditor::Document*)), this, SLOT(documentNameChanged()));
connect(m_view->document(), SIGNAL(documentNameChanged(KTextEditor::Document*)), this, SLOT(documentNameChanged()));
connect(m_view->document(), SIGNAL(readWriteChanged(KTextEditor::Document*)), this, SLOT(documentNameChanged()));
connect(m_view->document(),SIGNAL(documentUrlChanged(KTextEditor::Document*)), this, SLOT(urlChanged()));
- connect(m_view->document(), SIGNAL(modeChanged(KTextEditor::Document*)), this, SLOT(modeChanged(KTextEditor::Document*)));
setAcceptDrops(true);
connect(m_view,SIGNAL(dropEventPass(QDropEvent*)),this,SLOT(slotDropEvent(QDropEvent*)));
@@ -120,7 +112,7 @@ KWrite::KWrite (KTextEditor::Document *doc)
winList.append (this);
- updateStatus ();
+ documentNameChanged ();
show ();
// give view focus
@@ -194,41 +186,6 @@ void KWrite::setupActions()
}
-void KWrite::setupStatusBar()
-{
- // statusbar stuff
- QString lineColText = i18nc("@info:status Statusbar label for cursor line and column position",
- " Line: %1 Col: %2 ", 4444, 44);
-
- m_lineColLabel = new QLabel( statusBar() );
- m_lineColLabel->setMinimumWidth( m_lineColLabel->fontMetrics().width( lineColText ) );
- statusBar()->addWidget( m_lineColLabel, 0 );
-
- m_modifiedLabel = new QLabel( statusBar() );
- m_modifiedLabel->setFixedSize( 16, 16 );
- statusBar()->addWidget( m_modifiedLabel, 0 );
- m_modifiedLabel->setAlignment( Qt::AlignCenter );
-
- m_selectModeLabel = new QLabel( i18nc("@info:status Statusbar label for line selection mode", " LINE "), statusBar() );
- statusBar()->addWidget( m_selectModeLabel, 0 );
- m_selectModeLabel->setAlignment( Qt::AlignCenter );
-
- m_insertModeLabel = new QLabel( i18n(" INS "), statusBar() );
- statusBar()->addWidget( m_insertModeLabel, 0 );
- m_insertModeLabel->setAlignment( Qt::AlignCenter );
-
- m_modeLabel = new QLabel( QString(), statusBar() );
- statusBar()->addWidget( m_modeLabel, 0 );
- m_modeLabel->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
-
- m_fileNameLabel=new KSqueezedTextLabel( statusBar() );
- statusBar()->addPermanentWidget( m_fileNameLabel, 1 );
- m_fileNameLabel->setTextFormat(Qt::PlainText);
- m_fileNameLabel->setMinimumSize( 0, 0 );
- m_fileNameLabel->setSizePolicy(QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed ));
- m_fileNameLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
-}
-
// load on url
void KWrite::loadURL(const QUrl &url)
{
@@ -317,10 +274,10 @@ void KWrite::newView()
void KWrite::toggleStatusBar()
{
- if( m_paShowStatusBar->isChecked() )
+ /* FIXME KF5 if( m_paShowStatusBar->isChecked() )
statusBar()->show();
else
- statusBar()->hide();
+ statusBar()->hide();*/
}
void KWrite::editKeys()
@@ -399,10 +356,12 @@ void KWrite::readConfig(KSharedConfigPtr config)
if (config != KSharedConfig::openConfig())
KTextEditor::Editor::instance()->readConfig(config.data());
+ /* FIXME KF5
if( m_paShowStatusBar->isChecked() )
statusBar()->show();
else
statusBar()->hide();
+ */
}
void KWrite::writeConfig(KSharedConfigPtr config)
@@ -522,77 +481,8 @@ void KWrite::aboutEditor()
dlg.exec();
}
-void KWrite::updateStatus ()
-{
- viewModeChanged (m_view);
- cursorPositionChanged (m_view);
- selectionChanged (m_view);
- modifiedChanged ();
- documentNameChanged ();
- modeChanged (m_view->document());
-}
-
-void KWrite::viewModeChanged ( KTextEditor::View *view )
-{
- m_insertModeLabel->setText( view->viewMode() );
-}
-
-void KWrite::cursorPositionChanged ( KTextEditor::View *view )
-{
- KTextEditor::Cursor position (view->cursorPositionVirtual());
-
- m_lineColLabel->setText(
- i18nc("@info:status Statusbar label for cursor line and column position",
- " Line: %1 Col: %2 ", position.line()+1, position.column()+1) ) ;
-}
-
-void KWrite::selectionChanged (KTextEditor::View *view)
-{
- m_selectModeLabel->setText(
- view->blockSelection() ? i18nc("@info:status Statusbar label for block selection mode", " BLOCK ") :
- i18nc("@info:status Statusbar label for line selection mode", " LINE ") );
-}
-
-void KWrite::informationMessage (KTextEditor::View *view, const QString &message)
-{
- Q_UNUSED(view)
-
- m_fileNameLabel->setText( message );
-
- // timer to reset this after 4 seconds
- QTimer::singleShot(4000, this, SLOT(documentNameChanged()));
-}
-
-void KWrite::modifiedChanged()
-{
- bool mod = m_view->document()->isModified();
-
- if (mod && m_modPm.isNull()) {
- m_modPm = QIcon::fromTheme(QStringLiteral("document-properties")).pixmap(16);
- }
-
- /* const KateDocumentInfo *info
- = KateDocManager::self()->documentInfo ( m_view->document() );
-*/
-// bool modOnHD = false; //info && info->modifiedOnDisc;
-
- m_modifiedLabel->setPixmap(
- mod ? m_modPm : QPixmap()
- /*info && modOnHD ?
- m_modmodPm :
- m_modPm :
- info && modOnHD ?
- m_modDiscPm :
- QPixmap()*/
- );
-
- documentNameChanged(); // update the modified flag in window title
-}
-
void KWrite::documentNameChanged ()
{
- m_fileNameLabel->setText( QString::fromLatin1(" %1 ").arg (KStringHandler::lsqueeze(m_view->document()->documentName (), 64)));
-
QString readOnlyCaption;
if (!m_view->document()->isReadWrite())
readOnlyCaption=i18n(" [read only]");
@@ -623,11 +513,3 @@ void KWrite::documentNameChanged ()
setCaption (c+readOnlyCaption, m_view->document()->isModified());
}
}
-
-void KWrite::modeChanged ( KTextEditor::Document *document )
-{
- QString mode = document->mode();
- if (!mode.isEmpty())
- mode = i18nc("Language", document->mode().toUtf8().data());
- m_modeLabel->setText(mode);
-}
diff --git a/kwrite/kwrite.h b/kwrite/kwrite.h
index 514b710..6898aab 100644
--- a/kwrite/kwrite.h
+++ b/kwrite/kwrite.h
@@ -56,7 +56,6 @@ class KWrite : public KParts::MainWindow
private:
void setupActions();
- void setupStatusBar();
bool queryClose();
@@ -121,34 +120,8 @@ class KWrite : public KParts::MainWindow
static QList<KTextEditor::Document*> docList;
static QList<KWrite*> winList;
- /**
- * Stuff for the status bar
- */
public Q_SLOTS:
- void updateStatus ();
-
- void viewModeChanged ( KTextEditor::View *view );
-
- void modeChanged ( KTextEditor::Document *document );
-
- void cursorPositionChanged ( KTextEditor::View *view );
-
- void selectionChanged (KTextEditor::View *view);
-
- void modifiedChanged();
-
void documentNameChanged ();
-
- void informationMessage (KTextEditor::View *view, const QString &message);
-
- private:
- QLabel* m_lineColLabel;
- QLabel* m_modifiedLabel;
- QLabel* m_insertModeLabel;
- QLabel* m_selectModeLabel;
- QLabel* m_modeLabel;
- KSqueezedTextLabel* m_fileNameLabel;
- QPixmap m_modPm; //, m_modDiscPm, m_modmodPm;
};
#endif