From 91d242c991462a3c79affe72fac6fab143cbc343 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 13 Dec 2009 13:30:09 +0000 Subject: {alias,action,event,raw,popup}editor: don't use a supplementary widget to handle layout and resize events (should fix #642) input editor: code cleaning git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3694 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/actioneditor/actioneditor.cpp | 31 +++++++++++-------------------- src/modules/actioneditor/actioneditor.h | 2 -- src/modules/aliaseditor/aliaseditor.cpp | 31 +++++++++++++------------------ src/modules/aliaseditor/aliaseditor.h | 2 -- src/modules/eventeditor/eventeditor.cpp | 27 ++++++++++----------------- src/modules/eventeditor/eventeditor.h | 2 -- src/modules/popupeditor/popupeditor.cpp | 31 ++++++++++--------------------- src/modules/popupeditor/popupeditor.h | 2 -- src/modules/raweditor/raweditor.cpp | 27 +++++++++++---------------- src/modules/raweditor/raweditor.h | 2 -- 10 files changed, 55 insertions(+), 102 deletions(-) (limited to 'src/modules') diff --git a/src/modules/actioneditor/actioneditor.cpp b/src/modules/actioneditor/actioneditor.cpp index b05e1e408..079cee80e 100644 --- a/src/modules/actioneditor/actioneditor.cpp +++ b/src/modules/actioneditor/actioneditor.cpp @@ -856,31 +856,29 @@ KviActionEditorWindow::KviActionEditorWindow(KviFrame * lpFrm) g_pActionEditorWindow = this; setFixedCaption(__tr2qs_ctx("Action Editor","editor")); - m_pEditor = new KviActionEditor(this); + QGridLayout * g = new QGridLayout(); - m_pBase = new QWidget(this); - QGridLayout * g = new QGridLayout(m_pBase); + m_pEditor = new KviActionEditor(this); + g->addWidget(m_pEditor,0,0,1,4); - QPushButton * btn = new QPushButton(__tr2qs_ctx("OK","editor"),m_pBase); - btn->setMinimumWidth(80); + QPushButton * btn = new QPushButton(__tr2qs_ctx("OK","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(okClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,1); + g->addWidget(btn,1,1); - btn = new QPushButton(__tr2qs_ctx("Apply","editor"),m_pBase); - btn->setMinimumWidth(80); + btn = new QPushButton(__tr2qs_ctx("Apply","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(applyClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,2); + g->addWidget(btn,1,2); - btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),m_pBase); - btn->setMinimumWidth(80); + btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(cancelClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD))); - g->addWidget(btn,0,3); + g->addWidget(btn,1,3); + g->setRowStretch(0,1); g->setColumnStretch(0,1); - + setLayout(g); } KviActionEditorWindow::~KviActionEditorWindow() @@ -909,13 +907,6 @@ QPixmap * KviActionEditorWindow::myIconPtr() return g_pIconManager->getSmallIcon(KVI_SMALLICON_SCRIPTACTION); } -void KviActionEditorWindow::resizeEvent(QResizeEvent *) -{ - int hght = m_pBase->sizeHint().height(); - m_pEditor->setGeometry(0,0,width(),height()- hght); - m_pBase->setGeometry(0,height() - hght,width(),hght); -} - void KviActionEditorWindow::getConfigGroupName(QString &szName) { szName = "actioneditor"; diff --git a/src/modules/actioneditor/actioneditor.h b/src/modules/actioneditor/actioneditor.h index 3c3be4bbd..dc8ea08b6 100644 --- a/src/modules/actioneditor/actioneditor.h +++ b/src/modules/actioneditor/actioneditor.h @@ -188,10 +188,8 @@ public: ~KviActionEditorWindow(); protected: KviActionEditor * m_pEditor; - QWidget * m_pBase; protected: virtual QPixmap * myIconPtr(); - virtual void resizeEvent(QResizeEvent *e); virtual void getConfigGroupName(QString &szName); virtual void saveProperties(KviConfig *); virtual void loadProperties(KviConfig *); diff --git a/src/modules/aliaseditor/aliaseditor.cpp b/src/modules/aliaseditor/aliaseditor.cpp index 1e7bbdf47..e66bb5798 100644 --- a/src/modules/aliaseditor/aliaseditor.cpp +++ b/src/modules/aliaseditor/aliaseditor.cpp @@ -1415,7 +1415,7 @@ void KviAliasEditor::renameItem() // the name is changed explicitly with renameItem(), when needed void KviAliasEditor::saveLastEditedItem() { - if(!itemExists(m_pLastEditedItem)){debug("Item does not exists");return;} // dead ? + if(!itemExists(m_pLastEditedItem)) return; // dead ? ((KviAliasTreeWidgetItem *)m_pLastEditedItem)->setCursorPosition(m_pEditor->getCursor()); if(!m_pLastEditedItem || !m_pEditor->isModified()) return; if(m_pLastEditedItem->isNamespace())return; @@ -1555,27 +1555,29 @@ KviAliasEditorWindow::KviAliasEditorWindow(KviFrame * lpFrm) setFixedCaption(__tr2qs_ctx("Alias Editor","editor")); - m_pEditor = new KviAliasEditor(this); - - m_pBase = new QWidget(this); - QGridLayout * g = new QGridLayout(m_pBase); + QGridLayout * g = new QGridLayout(); - QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),m_pBase); + m_pEditor = new KviAliasEditor(this); + g->addWidget(m_pEditor,0,0,1,4); + + QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(okClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,1); + g->addWidget(btn,1,1); - btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),m_pBase); + btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(applyClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,2); + g->addWidget(btn,1,2); - btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),m_pBase); + btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(cancelClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD))); - g->addWidget(btn,0,3); + g->addWidget(btn,1,3); + g->setRowStretch(0,1); g->setColumnStretch(0,1); + setLayout(g); } KviAliasEditorWindow::~KviAliasEditorWindow() @@ -1604,13 +1606,6 @@ QPixmap * KviAliasEditorWindow::myIconPtr() return g_pIconManager->getSmallIcon(KVI_SMALLICON_ALIAS); } -void KviAliasEditorWindow::resizeEvent(QResizeEvent *) -{ - int hght = m_pBase->sizeHint().height(); - m_pEditor->setGeometry(0,0,width(),height()- hght); - m_pBase->setGeometry(0,height() - hght,width(),hght); -} - void KviAliasEditorWindow::getConfigGroupName(QString &szName) { szName = "aliaseditor"; diff --git a/src/modules/aliaseditor/aliaseditor.h b/src/modules/aliaseditor/aliaseditor.h index 154fbaf46..2a2c3ab83 100644 --- a/src/modules/aliaseditor/aliaseditor.h +++ b/src/modules/aliaseditor/aliaseditor.h @@ -203,10 +203,8 @@ public: ~KviAliasEditorWindow(); protected: KviAliasEditor * m_pEditor; - QWidget * m_pBase; protected: virtual QPixmap * myIconPtr(); - virtual void resizeEvent(QResizeEvent *e); virtual void getConfigGroupName(QString &szName); virtual void saveProperties(KviConfig *); virtual void loadProperties(KviConfig *); diff --git a/src/modules/eventeditor/eventeditor.cpp b/src/modules/eventeditor/eventeditor.cpp index c99778c30..4e9daba03 100644 --- a/src/modules/eventeditor/eventeditor.cpp +++ b/src/modules/eventeditor/eventeditor.cpp @@ -498,27 +498,28 @@ KviEventEditorWindow::KviEventEditorWindow(KviFrame * lpFrm) { g_pEventEditorWindow = this; + QGridLayout * g = new QGridLayout(); m_pEditor = new KviEventEditor(this); + g->addWidget(m_pEditor,0,0,1,4); - m_pBase = new QWidget(this); - QGridLayout * g = new QGridLayout(m_pBase); - - QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),m_pBase); + QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(okClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,1); + g->addWidget(btn,1,1); - btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),m_pBase); + btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(applyClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,2); + g->addWidget(btn,1,2); - btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),m_pBase); + btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(cancelClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD))); - g->addWidget(btn,0,3); + g->addWidget(btn,1,3); + g->setRowStretch(0,1); g->setColumnStretch(0,1); + setLayout(g); } KviEventEditorWindow::~KviEventEditorWindow() @@ -542,19 +543,11 @@ void KviEventEditorWindow::cancelClicked() close(); } - QPixmap * KviEventEditorWindow::myIconPtr() { return g_pIconManager->getSmallIcon(KVI_SMALLICON_EVENT); } -void KviEventEditorWindow::resizeEvent(QResizeEvent *) -{ - int hght = m_pBase->sizeHint().height(); - m_pEditor->setGeometry(0,0,width(),height()- hght); - m_pBase->setGeometry(0,height() - hght,width(),hght); -} - void KviEventEditorWindow::fillCaptionBuffers() { m_szPlainTextCaption = __tr2qs_ctx("Event Editor","editor"); diff --git a/src/modules/eventeditor/eventeditor.h b/src/modules/eventeditor/eventeditor.h index 52794fb4d..5770aab49 100644 --- a/src/modules/eventeditor/eventeditor.h +++ b/src/modules/eventeditor/eventeditor.h @@ -120,11 +120,9 @@ public: ~KviEventEditorWindow(); protected: KviEventEditor * m_pEditor; - QWidget * m_pBase; protected: virtual QPixmap * myIconPtr(); virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent *e); virtual void getConfigGroupName(QString &szName); virtual void saveProperties(KviConfig *); virtual void loadProperties(KviConfig *); diff --git a/src/modules/popupeditor/popupeditor.cpp b/src/modules/popupeditor/popupeditor.cpp index 7a48627b6..6dda5fe8e 100644 --- a/src/modules/popupeditor/popupeditor.cpp +++ b/src/modules/popupeditor/popupeditor.cpp @@ -1303,27 +1303,28 @@ KviPopupEditorWindow::KviPopupEditorWindow(KviFrame * lpFrm) { g_pPopupEditorWindow = this; + QGridLayout * g = new QGridLayout(); m_pEditor = new KviPopupEditor(this); + g->addWidget(m_pEditor,0,0,1,4); - m_pBase = new QWidget(this); - QGridLayout * g = new QGridLayout(m_pBase); - - QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),m_pBase); + QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(okClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,1); + g->addWidget(btn,1,1); - btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),m_pBase); + btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(applyClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,2); + g->addWidget(btn,1,2); - btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),m_pBase); + btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(cancelClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD))); - g->addWidget(btn,0,3); + g->addWidget(btn,1,3); + g->setRowStretch(0,1); g->setColumnStretch(0,1); + setLayout(g); } KviPopupEditorWindow::~KviPopupEditorWindow() @@ -1352,23 +1353,11 @@ QPixmap * KviPopupEditorWindow::myIconPtr() return g_pIconManager->getSmallIcon(KVI_SMALLICON_POPUP); } -void KviPopupEditorWindow::resizeEvent(QResizeEvent *) -{ - if(m_pBase) - { - int hght = m_pBase->sizeHint().height(); - if(m_pEditor) - m_pEditor->setGeometry(0,0,width(),height() - hght); - m_pBase->setGeometry(0, height() - hght, width(), hght); - } -} - void KviPopupEditorWindow::fillCaptionBuffers() { m_szPlainTextCaption = __tr2qs_ctx("Popup Editor","editor"); } - void KviPopupEditorWindow::getConfigGroupName(QString &szName) { szName = "popupeditor"; diff --git a/src/modules/popupeditor/popupeditor.h b/src/modules/popupeditor/popupeditor.h index 0aaeb68bd..67f2a90e1 100644 --- a/src/modules/popupeditor/popupeditor.h +++ b/src/modules/popupeditor/popupeditor.h @@ -188,11 +188,9 @@ public: ~KviPopupEditorWindow(); protected: KviPopupEditor * m_pEditor; - QWidget * m_pBase; protected: virtual QPixmap * myIconPtr(); virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent *e); virtual void getConfigGroupName(QString &szName); virtual void saveProperties(KviConfig *); virtual void loadProperties(KviConfig *); diff --git a/src/modules/raweditor/raweditor.cpp b/src/modules/raweditor/raweditor.cpp index 42bd2a487..67f5ad225 100644 --- a/src/modules/raweditor/raweditor.cpp +++ b/src/modules/raweditor/raweditor.cpp @@ -473,27 +473,29 @@ KviRawEditorWindow::KviRawEditorWindow(KviFrame * lpFrm) { g_pRawEditorWindow = this; - m_pEditor = new KviRawEditor(this); + QGridLayout * g = new QGridLayout(); - m_pBase = new QWidget(this); - QGridLayout * g = new QGridLayout(m_pBase); + m_pEditor = new KviRawEditor(this); + g->addWidget(m_pEditor,0,0,1,4); - QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),m_pBase); + QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(okClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,1); + g->addWidget(btn,1,1); - btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),m_pBase); + btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(applyClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT))); - g->addWidget(btn,0,2); + g->addWidget(btn,1,2); - btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),m_pBase); + btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),this); connect(btn,SIGNAL(clicked()),this,SLOT(cancelClicked())); btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD))); - g->addWidget(btn,0,3); + g->addWidget(btn,1,3); + g->setRowStretch(0,1); g->setColumnStretch(0,1); + setLayout(g); } KviRawEditorWindow::~KviRawEditorWindow() @@ -522,13 +524,6 @@ QPixmap * KviRawEditorWindow::myIconPtr() return g_pIconManager->getSmallIcon(KVI_SMALLICON_RAWEVENT); } -void KviRawEditorWindow::resizeEvent(QResizeEvent *) -{ - int hght = m_pBase->sizeHint().height(); - m_pEditor->setGeometry(0,0,width(),height()- hght); - m_pBase->setGeometry(0,height() - hght,width(),hght); -} - void KviRawEditorWindow::fillCaptionBuffers() { m_szPlainTextCaption = __tr2qs_ctx("Raw Editor","editor"); diff --git a/src/modules/raweditor/raweditor.h b/src/modules/raweditor/raweditor.h index 1a9133f4a..541122b15 100644 --- a/src/modules/raweditor/raweditor.h +++ b/src/modules/raweditor/raweditor.h @@ -128,11 +128,9 @@ public: ~KviRawEditorWindow(); protected: KviRawEditor * m_pEditor; - QWidget * m_pBase; protected: virtual QPixmap * myIconPtr(); virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent *e); virtual void getConfigGroupName(QString &szName); virtual void saveProperties(KviConfig *); virtual void loadProperties(KviConfig *); -- cgit v1.3.1-10-gc9f91