aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar IceN9ne2017-04-01 04:55:15 -0400
committerGravatar IceN9ne2017-04-01 04:55:15 -0400
commit42aee8a6e4b57ef238ba0218310f1d85b3f7afdd (patch)
tree5015b923711d6b98d299c9cde16cbf6a0b9ff64a /src
parentfix: hide comments in issues in new posts (#2213) (diff)
downloadKVIrc-42aee8a6e4b57ef238ba0218310f1d85b3f7afdd.tar.gz
KVIrc-42aee8a6e4b57ef238ba0218310f1d85b3f7afdd.tar.bz2
KVIrc-42aee8a6e4b57ef238ba0218310f1d85b3f7afdd.zip
window module: Finish window.setBackground
Diffstat (limited to 'src')
-rw-r--r--src/kvirc/ui/KviChannelWindow.cpp4
-rw-r--r--src/kvirc/ui/KviIrcView.h1
-rw-r--r--src/modules/window/libkviwindow.cpp37
3 files changed, 35 insertions, 7 deletions
diff --git a/src/kvirc/ui/KviChannelWindow.cpp b/src/kvirc/ui/KviChannelWindow.cpp
index 069f8286a..c2a229f15 100644
--- a/src/kvirc/ui/KviChannelWindow.cpp
+++ b/src/kvirc/ui/KviChannelWindow.cpp
@@ -440,8 +440,8 @@ void KviChannelWindow::showDoubleView(bool bShow)
if(!(m_pDoubleViewButton->isChecked()))
m_pDoubleViewButton->setChecked(true);
- if(m_privateBackground.pixmap())
- m_pMessageView->setPrivateBackgroundPixmap(*(m_privateBackground.pixmap()));
+ if(m_pIrcView->hasPrivateBackgroundPixmap())
+ m_pMessageView->setPrivateBackgroundPixmap(*(m_pIrcView->getPrivateBackgroundPixmap()));
connect(m_pMessageView, SIGNAL(rightClicked()), this, SLOT(textViewRightClicked()));
m_pMessageView->setMasterView(m_pIrcView);
diff --git a/src/kvirc/ui/KviIrcView.h b/src/kvirc/ui/KviIrcView.h
index 18f7e0341..8f13c3f08 100644
--- a/src/kvirc/ui/KviIrcView.h
+++ b/src/kvirc/ui/KviIrcView.h
@@ -176,6 +176,7 @@ public:
KviConsoleWindow * console();
// A null pixmap passed here unsets the private backgrdound.
void setPrivateBackgroundPixmap(const QPixmap & pixmap, bool bRepaint = true);
+ QPixmap * getPrivateBackgroundPixmap() const noexcept { return m_pPrivateBackgroundPixmap; };
bool hasPrivateBackgroundPixmap() { return (m_pPrivateBackgroundPixmap != 0); };
// Logging
diff --git a/src/modules/window/libkviwindow.cpp b/src/modules/window/libkviwindow.cpp
index 30baddb9e..25b6e2df9 100644
--- a/src/modules/window/libkviwindow.cpp
+++ b/src/modules/window/libkviwindow.cpp
@@ -1328,13 +1328,13 @@ static bool window_kvs_fnc_inputText(KviKvsModuleFunctionCall * c)
@short:
Sets the background image of a window
@syntax:
- window.setBackground [-q] <window_id:integer> <image_id:string>
+ window.setBackground [-q] <window_id:integer> [image_id:string]
@switches:
!sw: -q | --quiet
Be quiet
@description:
Sets the background image of the window specified by <window_id> to <image_id>.[br]
- If <window_id> is an empty string then the current window is assumed.[br]
+ If <image_id> is not provided, then the background is cleared and reset to global setting.[br]
If the specified window or the background image does not exist a warning is printed unless the -q switch is used.
@seealso:
*/
@@ -1343,19 +1343,46 @@ static bool window_kvs_cmd_setBackground(KviKvsModuleCommandCall * c)
{
QString szWnd;
QString szBackground;
- KviWindow * pWnd;
KVSM_PARAMETERS_BEGIN(c)
KVSM_PARAMETER("window_id", KVS_PT_STRING, 0, szWnd)
- KVSM_PARAMETER("plain_text_caption", KVS_PT_STRING, 0, szBackground)
+ KVSM_PARAMETER("background_path", KVS_PT_STRING, KVS_PF_OPTIONAL, szBackground)
KVSM_PARAMETERS_END(c)
- pWnd = g_pApp->findWindow(szWnd.toUtf8().data());
+ KviWindow * pWnd = g_pApp->findWindow(szWnd.toUtf8().data());
if(!pWnd)
{
if(!c->hasSwitch('q', "quiet"))
c->warning(__tr2qs("The window with ID '%s' doesn't exist"), szWnd.toUtf8().data());
return true;
}
+
+ if(!pWnd->view())
+ {
+ if(!c->hasSwitch('q', "quiet"))
+ c->warning(__tr2qs("The window with ID '%s' does not support background images!"));
+ return true;
+ }
+
+ QPixmap p;
+ if(!szBackground.isEmpty())
+ {
+ p = QPixmap(szBackground);
+ if(p.isNull())
+ {
+ if(!c->hasSwitch('q', "quiet"))
+ c->warning(__tr2qs("Failed to load the selected image!"));
+ return true;
+ }
+ }
+
+ pWnd->view()->setPrivateBackgroundPixmap(p);
+ if(pWnd->isChannel())
+ {
+ KviChannelWindow * pChanWin = (KviChannelWindow *)pWnd;
+ if(pChanWin->messageView())
+ pChanWin->messageView()->setPrivateBackgroundPixmap(p);
+ }
+
return true;
}