From: <hep...@us...> - 2008-10-29 16:18:50
|
Revision: 518 http://qterm.svn.sourceforge.net/qterm/?rev=518&view=rev Author: hephooey Date: 2008-10-29 16:18:47 +0000 (Wed, 29 Oct 2008) Log Message: ----------- New domain name Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/ui/aboutdialog.ui Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-07-19 10:20:25 UTC (rev 517) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-10-29 16:18:47 UTC (rev 518) @@ -447,7 +447,7 @@ void Frame::homepage() { QString strCmd = m_pref.strHttp; - QString strUrl = "http://qterm.sourceforge.net"; + QString strUrl = "http://www.qterm.org"; if(strCmd.indexOf("%L")==-1) strCmd += " \"" + strUrl +"\""; Modified: trunk/qterm-qt4/src/ui/aboutdialog.ui =================================================================== --- trunk/qterm-qt4/src/ui/aboutdialog.ui 2008-07-19 10:20:25 UTC (rev 517) +++ trunk/qterm-qt4/src/ui/aboutdialog.ui 2008-10-29 16:18:47 UTC (rev 518) @@ -113,11 +113,11 @@ </rect> </property> <property name="text" > - <string>QTerm --- BBS Client for X Window 2001-2006, + <string>QTerm --- BBS Client for X Window 2001-2008, The QTerm Developers -http://qterm.sourceforge.net</string> +http://www.qterm.org</string> </property> </widget> </widget> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-18 11:25:14
|
Revision: 519 http://qterm.svn.sourceforge.net/qterm/?rev=519&view=rev Author: hephooey Date: 2008-11-18 11:25:08 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Clean up the code and format it using astyle Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-10-29 16:18:47 UTC (rev 518) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:25:08 UTC (rev 519) @@ -19,7 +19,14 @@ #include "qtermparam.h" #include "qtermtoolbutton.h" #include "statusBar.h" -//Added by qt3to4: +#include "aboutdialog.h" +#include "addrdialog.h" +#include "prefdialog.h" +#include "quickdialog.h" +#include "keydialog.h" +#include "trayicon.h" +#include "imageviewer.h" + #include <QPaintEvent> #include <QMouseEvent> #include <QFrame> @@ -31,21 +38,6 @@ #include <QShortcut> #include <QSignalMapper> -#include "aboutdialog.h" -#include "addrdialog.h" -#include "prefdialog.h" -#include "quickdialog.h" -#include "keydialog.h" -#include "trayicon.h" -#include "imageviewer.h" - -#if !defined(_OS_WIN32_) && !defined(Q_OS_WIN32) -#include <unistd.h> -#endif - -#include <stdlib.h> -#include <stdio.h> - #include <QTextCodec> #include <QApplication> #include <QMdiArea> @@ -81,1692 +73,1421 @@ //constructor Frame::Frame() - : QMainWindow( 0 ) + : QMainWindow(0) { - s_instance = this; - setAttribute(Qt::WA_DeleteOnClose); -//set the layout - //QFrame * vb = new QFrame(this); - //QVBoxLayout * vbLayout = new QVBoxLayout(this); - //vbLayout->setMargin(0); -// Q3VBox *vb = new Q3VBox( this ); -// FIXME:QFrame? - //vb->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); - m_MdiArea = new QMdiArea( this ); - setCentralWidget( m_MdiArea ); - //vbLayout->addWidget(ws); + s_instance = this; + setAttribute(Qt::WA_DeleteOnClose); - tray = 0; - trayMenu = 0; - connect(this, SIGNAL(toolBarPositionChanged(QToolBar*)), - this, SLOT(toolBarPosChanged(QToolBar*))); + m_MdiArea = new QMdiArea(this); + setCentralWidget(m_MdiArea); + tray = 0; + trayMenu = 0; + connect(this, SIGNAL(toolBarPositionChanged(QToolBar*)), + this, SLOT(toolBarPosChanged(QToolBar*))); + //create a tabbar in the hbox - tabBar=new QTabBar(statusBar()); - statusBar()->addWidget(tabBar,0); - connect(tabBar,SIGNAL(selected(int)),this,SLOT(selectionChanged(int))); - //tabBar->setShape(QTabBar::TriangularBelow); - tabBar->setShape(QTabBar:: RoundedSouth); - tabBar->setDrawBase(false); + tabBar = new QTabBar(statusBar()); + statusBar()->addWidget(tabBar, 0); + connect(tabBar, SIGNAL(selected(int)), this, SLOT(selectionChanged(int))); + //tabBar->setShape(QTabBar::TriangularBelow); + tabBar->setShape(QTabBar:: RoundedSouth); + tabBar->setDrawBase(false); //create a progress bar to notify the download process - m_pStatusBar = new QTerm::StatusBar(statusBar(), "mainStatusBar"); - statusBar()->addWidget(m_pStatusBar, 0); + m_pStatusBar = new QTerm::StatusBar(statusBar(), "mainStatusBar"); + statusBar()->addWidget(m_pStatusBar, 0); //create the window manager to deal with the window-tab-icon pairs - wndmgr=new WndMgr(this); + wndmgr = new WndMgr(this); - initShortcuts(); + initShortcuts(); //set menubar - initActions(); + initActions(); - addMainMenu(); + addMainMenu(); //setup toolbar - addMainTool(); + addMainTool(); // add the custom defined key - updateKeyToolBar(); + updateKeyToolBar(); // diaable some menu & toolbar - enableMenuToolBar( false ); + enableMenuToolBar(false); //initialize all settings - iniSetting(); + iniSetting(); - initThemesMenu(); + initThemesMenu(); - installEventFilter(this); + installEventFilter(this); } //destructor Frame::~Frame() { - delete wndmgr; + delete wndmgr; } + //initialize setting from qterm.cfg void Frame::iniSetting() { - Config * conf= Global::instance()->fileCfg(); + Config * conf = Global::instance()->fileCfg(); - QString strTmp; - + QString strTmp; - strTmp = conf->getItemValue("global","fullscreen"); - if(strTmp=="1") - { - m_bFullScreen = true; - m_fullAction->setChecked( true ); - showFullScreen(); - } - else - { - m_bFullScreen = false; - //window size - strTmp = conf->getItemValue("global","max"); - if(strTmp=="1") - showMaximized(); - else - { - QString size = conf->getItemValue("global","size"); - if( !size.isNull() ) - { - int x,y,cx,cy; - sscanf(size.toLatin1(),"%d %d %d %d",&x,&y,&cx,&cy); - resize(QSize(cx,cy)); - move(QPoint(x,y)); - } - } - } - theme = conf->getItemValue("global","theme"); - QStyle * style = QStyleFactory::create(theme); - if (style) - qApp->setStyle(style); - - //language - strTmp = conf->getItemValue("global","language"); - if(strTmp=="eng") - m_engAction->setChecked( true ); - else if(strTmp=="chs") - m_chsAction->setChecked( true ); - else if(strTmp=="cht") - m_chtAction->setChecked( true ); - else - m_engAction->setChecked( true ); + strTmp = conf->getItemValue("global", "fullscreen"); + if (strTmp == "1") { + m_bFullScreen = true; + m_fullAction->setChecked(true); + showFullScreen(); + } else { + m_bFullScreen = false; + //window size + strTmp = conf->getItemValue("global", "max"); + if (strTmp == "1") + showMaximized(); + else { + QString size = conf->getItemValue("global", "size"); + if (!size.isNull()) { + int x, y, cx, cy; + sscanf(size.toLatin1(), "%d %d %d %d", &x, &y, &cx, &cy); + resize(QSize(cx, cy)); + move(QPoint(x, y)); + } + } + } - m_noescAction->setChecked( true ); - m_strEscape = ""; + theme = conf->getItemValue("global", "theme"); + QStyle * style = QStyleFactory::create(theme); + if (style) + qApp->setStyle(style); - strTmp = conf->getItemValue("global","clipcodec"); - if(strTmp=="0") - { - m_nClipCodec=0; - m_GBKAction->setChecked(true); - } - else - { - m_nClipCodec=1; - m_BIG5Action->setChecked(true); - } + //language + strTmp = conf->getItemValue("global", "language"); + if (strTmp == "eng") + m_engAction->setChecked(true); + else if (strTmp == "chs") + m_chsAction->setChecked(true); + else if (strTmp == "cht") + m_chtAction->setChecked(true); + else + m_engAction->setChecked(true); - strTmp = conf->getItemValue("global","vscrollpos"); - if(strTmp=="0") - { - m_nScrollPos=0; - m_scrollHideAction->setChecked(true); - } - else if(strTmp=="1") - { - m_nScrollPos=1; - m_scrollLeftAction->setChecked(true); - } - else - { - m_nScrollPos=2; - m_scrollRightAction->setChecked(true); - } + m_noescAction->setChecked(true); + m_strEscape = ""; - strTmp = conf->getItemValue("global","statusbar"); - m_bStatusBar = (strTmp!="0"); - m_statusAction->setChecked( m_bStatusBar ); + strTmp = conf->getItemValue("global", "clipcodec"); + if (strTmp == "0") { + m_nClipCodec = 0; + m_GBKAction->setChecked(true); + } else { + m_nClipCodec = 1; + m_BIG5Action->setChecked(true); + } - - strTmp = conf->getItemValue("global","switchbar"); - m_bSwitchBar = (strTmp!="0"); - m_switchAction->setChecked( m_bSwitchBar ); - if(m_bSwitchBar) - statusBar()->show(); - else - statusBar()->hide(); + strTmp = conf->getItemValue("global", "vscrollpos"); + if (strTmp == "0") { + m_nScrollPos = 0; + m_scrollHideAction->setChecked(true); + } else if (strTmp == "1") { + m_nScrollPos = 1; + m_scrollLeftAction->setChecked(true); + } else { + m_nScrollPos = 2; + m_scrollRightAction->setChecked(true); + } - m_bBossColor = false; + strTmp = conf->getItemValue("global", "statusbar"); + m_bStatusBar = (strTmp != "0"); + m_statusAction->setChecked(m_bStatusBar); - loadPref( conf ); - setUseDock(m_pref.bTray); + strTmp = conf->getItemValue("global", "switchbar"); + m_bSwitchBar = (strTmp != "0"); + m_switchAction->setChecked(m_bSwitchBar); + if (m_bSwitchBar) + statusBar()->show(); + else + statusBar()->hide(); + + m_bBossColor = false; + + loadPref(conf); + + setUseDock(m_pref.bTray); } -void Frame::loadPref( Config * conf ) +void Frame::loadPref(Config * conf) { - QString strTmp; - strTmp = conf->getItemValue("preference","xim"); - m_pref.nXIM = strTmp.toInt(); - strTmp = conf->getItemValue("preference","wordwrap"); - m_pref.nWordWrap = strTmp.toInt(); - strTmp = conf->getItemValue("preference","wheel"); - m_pref.bWheel=(strTmp!="0"); - strTmp = conf->getItemValue("preference","url"); - m_pref.bUrl=(strTmp!="0"); - strTmp = conf->getItemValue("preference","blinktab"); - m_pref.bBlinkTab=(strTmp!="0"); - strTmp = conf->getItemValue("preference","warn"); - m_pref.bWarn=(strTmp!="0"); - strTmp = conf->getItemValue("preference","beep"); - m_pref.nBeep=strTmp.toInt(); - m_pref.strWave = conf->getItemValue("preference","wavefile"); - strTmp = conf->getItemValue("preference","http"); - m_pref.strHttp = strTmp; - strTmp = conf->getItemValue("preference","antialias"); - m_pref.bAA=(strTmp!="0"); - strTmp = conf->getItemValue("preference","tray"); - m_pref.bTray=(strTmp!="0"); - strTmp = conf->getItemValue("preference","externalplayer"); - m_pref.strPlayer=strTmp; + QString strTmp; + strTmp = conf->getItemValue("preference", "xim"); + m_pref.nXIM = strTmp.toInt(); + strTmp = conf->getItemValue("preference", "wordwrap"); + m_pref.nWordWrap = strTmp.toInt(); + strTmp = conf->getItemValue("preference", "wheel"); + m_pref.bWheel = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "url"); + m_pref.bUrl = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "blinktab"); + m_pref.bBlinkTab = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "warn"); + m_pref.bWarn = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "beep"); + m_pref.nBeep = strTmp.toInt(); + m_pref.strWave = conf->getItemValue("preference", "wavefile"); + strTmp = conf->getItemValue("preference", "http"); + m_pref.strHttp = strTmp; + strTmp = conf->getItemValue("preference", "antialias"); + m_pref.bAA = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "tray"); + m_pref.bTray = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "externalplayer"); + m_pref.strPlayer = strTmp; - strTmp = conf->getItemValue("preference","clearpool"); - m_pref.bClearPool=(strTmp!="0"); - strTmp = conf->getItemValue("preference","pool"); - m_pref.strPoolPath=strTmp.isEmpty()?Global::instance()->pathCfg()+"pool/":strTmp; - if( m_pref.strPoolPath.right(1) != "/" ) - m_pref.strPoolPath.append('/'); - strTmp = conf->getItemValue("preference","zmodem"); - m_pref.strZmPath=strTmp.isEmpty()?Global::instance()->pathCfg()+"zmodem/":strTmp; - if( m_pref.strZmPath.right(1) != "/" ) - m_pref.strZmPath.append('/'); - strTmp = conf->getItemValue("preference","image"); - m_pref.strImageViewer=strTmp; + strTmp = conf->getItemValue("preference", "clearpool"); + m_pref.bClearPool = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "pool"); + m_pref.strPoolPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "pool/" : strTmp; + if (m_pref.strPoolPath.right(1) != "/") + m_pref.strPoolPath.append('/'); + strTmp = conf->getItemValue("preference", "zmodem"); + m_pref.strZmPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "zmodem/" : strTmp; + if (m_pref.strZmPath.right(1) != "/") + m_pref.strZmPath.append('/'); + strTmp = conf->getItemValue("preference", "image"); + m_pref.strImageViewer = strTmp; } //save current setting to qterm.cfg void Frame::saveSetting() { - Config * conf= Global::instance()->fileCfg(); + Config * conf = Global::instance()->fileCfg(); - QString strTmp; - //save font - conf->setItemValue("global","font",qApp->font().family()); - strTmp.setNum(QFontInfo(qApp->font()).pointSize()); - conf->setItemValue("global","pointsize",strTmp); - strTmp.setNum(QFontInfo(qApp->font()).pixelSize()); - conf->setItemValue("global","pixelsize",strTmp); + QString strTmp; + //save font + conf->setItemValue("global", "font", qApp->font().family()); + strTmp.setNum(QFontInfo(qApp->font()).pointSize()); + conf->setItemValue("global", "pointsize", strTmp); + strTmp.setNum(QFontInfo(qApp->font()).pixelSize()); + conf->setItemValue("global", "pixelsize", strTmp); - //save window position and size - if(isMaximized()) - { - conf->setItemValue("global","max","1"); - } - else - { - strTmp = QString("%1 %2 %3 %4").arg(x()).arg(y()).arg(width()).arg(height()); -// cstrTmp.sprintf("%d %d %d %d",x(),y(),width(),height()); - conf->setItemValue("global","size",strTmp); - conf->setItemValue("global","max","0"); - } - - if(m_bFullScreen) - conf->setItemValue("global","fullscreen","1"); - else - conf->setItemValue("global","fullscreen","0"); - - // cstrTmp.setNum(theme); - conf->setItemValue("global","theme",theme); + //save window position and size + if (isMaximized()) { + conf->setItemValue("global", "max", "1"); + } else { + strTmp = QString("%1 %2 %3 %4").arg(x()).arg(y()).arg(width()).arg(height()); +// cstrTmp.sprintf("%d %d %d %d",x(),y(),width(),height()); + conf->setItemValue("global", "size", strTmp); + conf->setItemValue("global", "max", "0"); + } - int hide,dock,index,nl,extra; + if (m_bFullScreen) + conf->setItemValue("global", "fullscreen", "1"); + else + conf->setItemValue("global", "fullscreen", "0"); - strTmp = conf->getItemValue("global", "bbsbar"); - sscanf(strTmp.toLatin1(),"%d %d %d %d %d",&hide,&dock,&index,&nl,&extra); - conf->setItemValue("global","bbsbar", valueToString(mdiconnectTools->isVisibleTo(this), - (int)dock, index, nl==1?true:false, extra)); + // cstrTmp.setNum(theme); + conf->setItemValue("global", "theme", theme); - strTmp = conf->getItemValue("global", "keybar"); - sscanf(strTmp.toLatin1(),"%d %d %d %d %d",&hide,&dock,&index,&nl,&extra); - conf->setItemValue("global","keybar", valueToString(key->isVisibleTo(this), - (int)dock, index, nl==1?true:false, extra)); + int hide, dock, index, nl, extra; - strTmp = conf->getItemValue("global", "mainbar"); - sscanf(strTmp.toLatin1(),"%d %d %d %d %d",&hide,&dock,&index,&nl,&extra); - conf->setItemValue("global","mainbar",valueToString(mdiTools->isVisibleTo(this), - (int)dock, index, nl==1?true:false, extra) ); + strTmp = conf->getItemValue("global", "bbsbar"); + sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); + conf->setItemValue("global", "bbsbar", valueToString(mdiconnectTools->isVisibleTo(this), + (int)dock, index, nl == 1 ? true : false, extra)); - - strTmp.setNum(m_nClipCodec); - conf->setItemValue("global","clipcodec",strTmp); + strTmp = conf->getItemValue("global", "keybar"); + sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); + conf->setItemValue("global", "keybar", valueToString(key->isVisibleTo(this), + (int)dock, index, nl == 1 ? true : false, extra)); - strTmp.setNum(m_nScrollPos); - conf->setItemValue("global","vscrollpos",strTmp); + strTmp = conf->getItemValue("global", "mainbar"); + sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); + conf->setItemValue("global", "mainbar", valueToString(mdiTools->isVisibleTo(this), + (int)dock, index, nl == 1 ? true : false, extra)); - conf->setItemValue("global","statusbar", m_bStatusBar?"1":"0"); - conf->setItemValue("global","switchbar", m_bSwitchBar?"1":"0"); - conf->save(); + strTmp.setNum(m_nClipCodec); + conf->setItemValue("global", "clipcodec", strTmp); + + strTmp.setNum(m_nScrollPos); + conf->setItemValue("global", "vscrollpos", strTmp); + + conf->setItemValue("global", "statusbar", m_bStatusBar ? "1" : "0"); + conf->setItemValue("global", "switchbar", m_bSwitchBar ? "1" : "0"); + + conf->save(); } //addressbook void Frame::addressBook() { - addrDialog addr(this,false); - - if(addr.exec()==1) - { - newWindow(addr.param, addr.ui.nameListWidget->currentRow()); - } + addrDialog addr(this, false); + + if (addr.exec() == 1) { + newWindow(addr.param, addr.ui.nameListWidget->currentRow()); + } } //quicklogin void Frame::quickLogin() { - quickDialog quick(this); + quickDialog quick(this); - Global::instance()->loadAddress(-1, quick.param); + Global::instance()->loadAddress(-1, quick.param); - if(quick.exec()==1) - { - newWindow(quick.param); - } + if (quick.exec() == 1) { + newWindow(quick.param); + } } void Frame::exitQTerm() { - while( wndmgr->count()>0 ) - { - bool closed = m_MdiArea->activeSubWindow()->close(); - if(!closed) - { - return; - } - } + while (wndmgr->count() > 0) { + bool closed = m_MdiArea->activeSubWindow()->close(); + if (!closed) { + return; + } + } - saveSetting(); - // clear zmodem and pool if needed - if(m_pref.bClearPool) - { - Global::instance()->clearDir(m_pref.strZmPath); - Global::instance()->clearDir(m_pref.strPoolPath); - Global::instance()->clearDir(m_pref.strPoolPath+"shadow-cache/"); - } + saveSetting(); + // clear zmodem and pool if needed + if (m_pref.bClearPool) { + Global::instance()->clearDir(m_pref.strZmPath); + Global::instance()->clearDir(m_pref.strPoolPath); + Global::instance()->clearDir(m_pref.strPoolPath + "shadow-cache/"); + } - setUseDock(false); - qApp->quit(); + setUseDock(false); + qApp->quit(); } //create a new display window -//Window * Frame::newWindow( const Param& param, int index ) -void Frame::newWindow( const Param& param, int index ) +void Frame::newWindow(const Param& param, int index) { - Window * window=new Window( this, param, index, m_MdiArea, - 0 ); - QString pathLib = Global::instance()->pathLib(); - m_MdiArea->addSubWindow(window); - window->setWindowTitle( param.m_strName ); - window->setWindowIcon( QPixmap(pathLib+"pic/tabpad.png") ); - window->setAttribute(Qt::WA_DeleteOnClose); + Window * window = new Window(this, param, index, m_MdiArea, + 0); + QString pathLib = Global::instance()->pathLib(); + m_MdiArea->addSubWindow(window); + window->setWindowTitle(param.m_strName); + window->setWindowIcon(QPixmap(pathLib + "pic/tabpad.png")); + window->setAttribute(Qt::WA_DeleteOnClose); - QIcon* icon = new QIcon(QPixmap(pathLib+"pic/tabpad.png")); - //QTab *qtab=new QTab(*icon,window->caption()); - QString qtab = window->windowTitle(); + QIcon* icon = new QIcon(QPixmap(pathLib + "pic/tabpad.png")); + QString qtab = window->windowTitle(); - //add window-tab-icon to window manager - wndmgr->addWindow(window); - tabBar->addTab( *icon, qtab ); - - window->setFocus(); - window->showMaximized(); + //add window-tab-icon to window manager + wndmgr->addWindow(window); + tabBar->addTab(*icon, qtab); - //activte the window-tab -// window->setFocus(); -// wndmgr->activateTheTab(window); + window->setFocus(); + window->showMaximized(); -// return window; } //the tabbar selection changed void Frame::selectionChanged(int n) { - wndmgr->activateTheWindow(n); + wndmgr->activateTheWindow(n); } + //slot Help->About QTerm void Frame::aboutQTerm() { - aboutDialog about(this); - - about.exec(); + aboutDialog about(this); + + about.exec(); } //slot Help->Homepage void Frame::homepage() { QString strCmd = m_pref.strHttp; - QString strUrl = "http://www.qterm.org"; + QString strUrl = "http://www.qterm.org"; - if(strCmd.indexOf("%L")==-1) - strCmd += " \"" + strUrl +"\""; + if (strCmd.indexOf("%L") == -1) + strCmd += " \"" + strUrl + "\""; else - strCmd.replace(QRegExp("%L",Qt::CaseInsensitive), strUrl); + strCmd.replace(QRegExp("%L", Qt::CaseInsensitive), strUrl); - #if !defined(_OS_WIN32_) && !defined(Q_OS_WIN32) - strCmd += " &"; - #endif - system(strCmd.toLocal8Bit()); +#if !defined(_OS_WIN32_) && !defined(Q_OS_WIN32) + strCmd += " &"; +#endif + system(strCmd.toLocal8Bit()); } + //slot Windows menu aboutToShow void Frame::windowsMenuAboutToShow() { - windowsMenu->clear(); - QAction * cascadeAction = windowsMenu->addAction(tr("Cascade"), m_MdiArea, SLOT(cascadeSubWindows() ) ); - QAction * tileAction = windowsMenu->addAction(tr("Tile"), m_MdiArea, SLOT(tileSubWindows() ) ); - if ( m_MdiArea->subWindowList().isEmpty() ) - { - cascadeAction->setEnabled(false); - tileAction->setEnabled(false); - } - windowsMenu->addSeparator(); + windowsMenu->clear(); + QAction * cascadeAction = windowsMenu->addAction(tr("Cascade"), m_MdiArea, SLOT(cascadeSubWindows())); + QAction * tileAction = windowsMenu->addAction(tr("Tile"), m_MdiArea, SLOT(tileSubWindows())); + if (m_MdiArea->subWindowList().isEmpty()) { + cascadeAction->setEnabled(false); + tileAction->setEnabled(false); + } + windowsMenu->addSeparator(); #ifdef Q_OS_MACX - // used to dock the programe - if(isHidden()) - windowsMenu->addAction(tr("Main Window"), this, SLOT(trayShow())); + // used to dock the programe + if (isHidden()) + windowsMenu->addAction(tr("Main Window"), this, SLOT(trayShow())); #endif - QList<QMdiSubWindow *> windows = m_MdiArea->subWindowList(); - for ( int i = 0; i < int(windows.count()); ++i ) - { - QAction * idAction = windowsMenu->addAction(windows.at(i)->windowTitle(), - this, SLOT( windowsMenuActivated( int ) ) ); - idAction->setData(i); - idAction->setChecked(m_MdiArea->activeSubWindow() == windows.at(i)); - } - + QList<QMdiSubWindow *> windows = m_MdiArea->subWindowList(); + for (int i = 0; i < int(windows.count()); ++i) { + QAction * idAction = windowsMenu->addAction(windows.at(i)->windowTitle(), + this, SLOT(windowsMenuActivated(int))); + idAction->setData(i); + idAction->setChecked(m_MdiArea->activeSubWindow() == windows.at(i)); + } + } -//slot activate the window correspond with the menu id -void Frame::windowsMenuActivated( int id ) +//slot activate the window correspond with the menu id +void Frame::windowsMenuActivated(int id) { - QWidget* w = m_MdiArea->subWindowList().at( id ); - if ( w ) - { - w->showNormal(); -// wndmgr->activateTheTab((Window*)w); - } + QWidget* w = m_MdiArea->subWindowList().at(id); + if (w) { + w->showNormal(); + } } void Frame::popupConnectMenu() { - connectMenu->clear(); + connectMenu->clear(); - connectMenu->addAction("Quick Login", this, SLOT(quickLogin()) ); - connectMenu->addSeparator(); - - QStringList listName = Global::instance()->loadNameList(); - QSignalMapper * connectMapper = new QSignalMapper(this); + connectMenu->addAction("Quick Login", this, SLOT(quickLogin())); + connectMenu->addSeparator(); - for ( int i=0; i<listName.count(); i++ ) - { - QAction * idAction = new QAction(listName[i], connectMenu); - connectMenu->addAction(idAction); - connect(idAction, SIGNAL(triggered()), connectMapper, SLOT(map())); - connectMapper->setMapping(idAction, i); - } - connect(connectMapper, SIGNAL(mapped(int)), this, SLOT(connectMenuActivated(int))); - //connectMenu->exec( connectButton->mapToGlobal( connectButton->rect().bottomLeft() )); -} + QStringList listName = Global::instance()->loadNameList(); + QSignalMapper * connectMapper = new QSignalMapper(this); -void Frame::connectMenuAboutToHide() -{ -// QMouseEvent me( QEvent::MouseButtonRelease, QPoint(0,0), QPoint(0,0), -// Qt::LeftButton, Qt::NoButton, Qt::NoModifier); -// QApplication::sendEvent( connectButton, &me ); - + for (int i = 0; i < listName.count(); i++) { + QAction * idAction = new QAction(listName[i], connectMenu); + connectMenu->addAction(idAction); + connect(idAction, SIGNAL(triggered()), connectMapper, SLOT(map())); + connectMapper->setMapping(idAction, i); + } + connect(connectMapper, SIGNAL(mapped(int)), this, SLOT(connectMenuActivated(int))); } + void Frame::connectMenuActivated(int id) { - Param param; - // FIXME: don't know the relation with id and param setted by setItemParameter - if(Global::instance()->loadAddress(id, param)) - newWindow(param, id); + Param param; + // FIXME: don't know the relation with id and param setted by setItemParameter + if (Global::instance()->loadAddress(id, param)) + newWindow(param, id); } void Frame::switchWin(int id) { - QList<QMdiSubWindow *> windows = m_MdiArea->subWindowList(); - if(windows.count() <= id) - return; + QList<QMdiSubWindow *> windows = m_MdiArea->subWindowList(); + if (windows.count() <= id) + return; - if(id==200) - { - wndmgr->activeNextPrev(false); - return; - } - if(id==201 || id==202) - { - wndmgr->activeNextPrev(true); - return; - } + if (id == 200) { + wndmgr->activeNextPrev(false); + return; + } + if (id == 201 || id == 202) { + wndmgr->activeNextPrev(true); + return; + } - QWidget *w = windows.at(id); - if(w == m_MdiArea->activeSubWindow() ) - return; + QWidget *w = windows.at(id); + if (w == m_MdiArea->activeSubWindow()) + return; - if(w!=NULL) { - w->setFocus(); - } + if (w != NULL) { + w->setFocus(); + } } -bool Frame::eventFilter(QObject *o, QEvent *e) -{ -/* - if( o==this && m_pref.bTray) - { - if( e->type()==QEvent::ShowMinimized && m_pref.bTray ) - { - printf("Frame::eventFilter\n"); - trayHide(); - return true; - } - } - return false; -*/ - return false; -} //slot draw something e.g. logo in the background //TODO : draw a pixmap in the background -void Frame::paintEvent( QPaintEvent * ) +void Frame::paintEvent(QPaintEvent *) { } void Frame::closeEvent(QCloseEvent * clse) { - QList<QMdiSubWindow *> windows = m_MdiArea->subWindowList(); - for ( int i = 0; i < int(windows.count()); ++i ) - { + QList<QMdiSubWindow *> windows = m_MdiArea->subWindowList(); + for (int i = 0; i < int(windows.count()); ++i) { - if( ( (Window *)windows.at(i) )->isConnected() ) - { - if (m_pref.bTray) { - trayHide(); - clse->ignore(); - return; - } - } + if (((Window *)windows.at(i))->isConnected()) { + if (m_pref.bTray) { + trayHide(); + clse->ignore(); + return; + } } - while( wndmgr->count()>0 ) - { - bool closed = m_MdiArea->activeSubWindow()->close(); - if(!closed) - { - clse->ignore(); - return; - } + } + while (wndmgr->count() > 0) { + bool closed = m_MdiArea->activeSubWindow()->close(); + if (!closed) { + clse->ignore(); + return; } + } - saveSetting(); - // clear zmodem and pool if needed - if(m_pref.bClearPool) - { - Global::instance()->clearDir(m_pref.strZmPath); - Global::instance()->clearDir(m_pref.strPoolPath); - Global::instance()->clearDir(m_pref.strPoolPath+"shadow-cache/"); - } + saveSetting(); + // clear zmodem and pool if needed + if (m_pref.bClearPool) { + Global::instance()->clearDir(m_pref.strZmPath); + Global::instance()->clearDir(m_pref.strPoolPath); + Global::instance()->clearDir(m_pref.strPoolPath + "shadow-cache/"); + } - setUseDock(false); + setUseDock(false); - clse->accept(); + clse->accept(); } void Frame::updateLang(QAction * action) { - QMessageBox::information( this, "QTerm", - tr("This will take effect after restart,\nplease close all windows and restart.")); - Config * conf= Global::instance()->fileCfg(); - conf->setItemValue("global","language",action->objectName()); - conf->save(); + QMessageBox::information(this, "QTerm", + tr("This will take effect after restart,\nplease close all windows and restart.")); + Config * conf = Global::instance()->fileCfg(); + conf->setItemValue("global", "language", action->objectName()); + conf->save(); } void Frame::connectIt() { - if( wndmgr->activeWindow()== NULL ) - { - Param param; - Global::instance()->loadAddress(-1, param); - newWindow( param ); - } - else - if(!wndmgr->activeWindow()->isConnected()) - wndmgr->activeWindow()->reconnect(); + if (wndmgr->activeWindow() == NULL) { + Param param; + Global::instance()->loadAddress(-1, param); + newWindow(param); + } else + if (!wndmgr->activeWindow()->isConnected()) + wndmgr->activeWindow()->reconnect(); } void Frame::disconnect() { - wndmgr->activeWindow()->disconnect(); + wndmgr->activeWindow()->disconnect(); } -void Frame::copy( ) +void Frame::copy() { - wndmgr->activeWindow()->copy(); + wndmgr->activeWindow()->copy(); } -void Frame::paste( ) +void Frame::paste() { - wndmgr->activeWindow()->paste(); + wndmgr->activeWindow()->paste(); } void Frame::copyRect(bool isEnabled) { - wndmgr->activeWindow()->m_bCopyRect = isEnabled; + wndmgr->activeWindow()->m_bCopyRect = isEnabled; } void Frame::copyColor(bool isEnabled) { - wndmgr->activeWindow()->m_bCopyColor = isEnabled; + wndmgr->activeWindow()->m_bCopyColor = isEnabled; } -void Frame::copyArticle( ) +void Frame::copyArticle() { - wndmgr->activeWindow()->copyArticle(); + wndmgr->activeWindow()->copyArticle(); } void Frame::autoCopy(bool isEnabled) { - wndmgr->activeWindow()->m_bAutoCopy = isEnabled; + wndmgr->activeWindow()->m_bAutoCopy = isEnabled; } void Frame::wordWrap(bool isEnabled) { - wndmgr->activeWindow()->m_bWordWrap = isEnabled; + wndmgr->activeWindow()->m_bWordWrap = isEnabled; } void Frame::updateESC(QAction * action) { - if (action->objectName() == "noesc") { - m_strEscape = ""; - } else if (action->objectName() == "escesc") { - m_strEscape = "^[^[["; - } else if (action->objectName() == "uesc") { - m_strEscape = "^u["; - } else if (action->objectName() == "custom") { - bool ok; - QString strEsc = QInputDialog::getText(this, "define escape", "scape string *[", QLineEdit::Normal, m_strEscape , &ok); - if(ok) - m_strEscape = strEsc; - } else { - qDebug("updateESC: should not be here"); - } + if (action->objectName() == "noesc") { + m_strEscape = ""; + } else if (action->objectName() == "escesc") { + m_strEscape = "^[^[["; + } else if (action->objectName() == "uesc") { + m_strEscape = "^u["; + } else if (action->objectName() == "custom") { + bool ok; + QString strEsc = QInputDialog::getText(this, "define escape", "scape string *[", QLineEdit::Normal, m_strEscape , &ok); + if (ok) + m_strEscape = strEsc; + } else { + qDebug("updateESC: should not be here"); + } } void Frame::updateCodec(QAction * action) { - if (action->objectName() == "GBK") { - m_nClipCodec=0; - } else if (action->objectName() == "Big5") { - m_nClipCodec=1; - } else { - qDebug("updateCodec: should not be here"); - } + if (action->objectName() == "GBK") { + m_nClipCodec = 0; + } else if (action->objectName() == "Big5") { + m_nClipCodec = 1; + } else { + qDebug("updateCodec: should not be here"); + } } -void Frame::font( ) +void Frame::font() { - wndmgr->activeWindow()->font(); + wndmgr->activeWindow()->font(); } -void Frame::color( ) +void Frame::color() { - wndmgr->activeWindow()->color(); + wndmgr->activeWindow()->color(); } -void Frame::refresh( ) +void Frame::refresh() { - wndmgr->activeWindow()->refresh(); + wndmgr->activeWindow()->refresh(); } void Frame::uiFont() { - bool ok; - QFont font = QFontDialog::getFont(&ok,qApp->font()); - - if(m_pref.bAA) - font.setStyleStrategy(QFont::PreferAntialias); - - if(ok==true) - { - qApp->setFont(font); - } + bool ok; + QFont font = QFontDialog::getFont(&ok, qApp->font()); + + if (m_pref.bAA) + font.setStyleStrategy(QFont::PreferAntialias); + + if (ok == true) { + qApp->setFont(font); + } } void Frame::fullscreen() { - m_bFullScreen = ! m_bFullScreen; - - if( m_bFullScreen ) - { - //TODO: add an item to the popup menu so we can go back to normal without touch the keyboard - menuBar()->hide(); - mdiTools->hide(); - mdiconnectTools->hide(); - key->hide(); - //showStatusBar(); - //showSwitchBar(); - showFullScreen(); - } - else - { - menuBar()->show(); - mdiTools->show(); - mdiconnectTools->show(); - key->show(); - emit scrollChanged(); - //showStatusBar(); - //showSwitchBar(); - showNormal(); - } + m_bFullScreen = ! m_bFullScreen; - m_fullAction->setChecked(m_bFullScreen); -// menuBar()->setItemChecked( ID_VIEW_FULL, m_bFullScreen ); + if (m_bFullScreen) { + //TODO: add an item to the popup menu so we can go back to normal without touch the keyboard + menuBar()->hide(); + mdiTools->hide(); + mdiconnectTools->hide(); + key->hide(); + //showStatusBar(); + //showSwitchBar(); + showFullScreen(); + } else { + menuBar()->show(); + mdiTools->show(); + mdiconnectTools->show(); + key->show(); + emit scrollChanged(); + //showStatusBar(); + //showSwitchBar(); + showNormal(); + } + m_fullAction->setChecked(m_bFullScreen); + } void Frame::bosscolor() { - m_bBossColor = !m_bBossColor; + m_bBossColor = !m_bBossColor; - emit bossColor(); - - m_bossAction->setChecked(m_bBossColor); -// menuBar()->setItemChecked( ID_VIEW_BOSS, m_bBossColor ); + emit bossColor(); + + m_bossAction->setChecked(m_bBossColor); } void Frame::initThemesMenu() { - themesMenu->clear(); - QActionGroup * themesGroup = new QActionGroup(this); - QStringList styles = QStyleFactory::keys(); - for(QStringList::ConstIterator it=styles.begin(); it!=styles.end(); it++) - themesGroup->addAction(insertThemeItem(*it)); - connect(themesGroup, SIGNAL(triggered(QAction* )), this, SLOT(themesMenuActivated(QAction*))); + themesMenu->clear(); + QActionGroup * themesGroup = new QActionGroup(this); + QStringList styles = QStyleFactory::keys(); + for (QStringList::ConstIterator it = styles.begin(); it != styles.end(); it++) + themesGroup->addAction(insertThemeItem(*it)); + connect(themesGroup, SIGNAL(triggered(QAction*)), this, SLOT(themesMenuActivated(QAction*))); } void Frame::themesMenuActivated(QAction * action) { - theme = action->text(); - QStyle * style = QStyleFactory::create(theme); - if (style) - qApp->setStyle(style); + theme = action->text(); + QStyle * style = QStyleFactory::create(theme); + if (style) + qApp->setStyle(style); } void Frame::updateScroll(QAction * action) { - if (action->objectName() == "Hide") { - m_nScrollPos = 0; - } else if (action->objectName() == "Left") { - m_nScrollPos = 1; - } else if (action->objectName() == "Right") { - m_nScrollPos = 2; - } else { - qDebug("updateScroll: should not be here"); - } - emit scrollChanged(); + if (action->objectName() == "Hide") { + m_nScrollPos = 0; + } else if (action->objectName() == "Left") { + m_nScrollPos = 1; + } else if (action->objectName() == "Right") { + m_nScrollPos = 2; + } else { + qDebug("updateScroll: should not be here"); + } + emit scrollChanged(); } void Frame::updateSwitchBar(bool isEnabled) { - m_bSwitchBar = isEnabled; - - if(m_bSwitchBar) - statusBar()->show(); - else - statusBar()->hide(); + m_bSwitchBar = isEnabled; + + if (m_bSwitchBar) + statusBar()->show(); + else + statusBar()->hide(); } void Frame::updateStatusBar(bool isEnabled) { - m_bStatusBar = isEnabled; - - emit statusBarChanged(m_bStatusBar); + m_bStatusBar = isEnabled; + + emit statusBarChanged(m_bStatusBar); } -void Frame::setting( ) +void Frame::setting() { - wndmgr->activeWindow()->setting(); + wndmgr->activeWindow()->setting(); } void Frame::defaultSetting() { - addrDialog set(this, true); + addrDialog set(this, true); - if( Global::instance()->addrCfg()->hasSection("default") ) - Global::instance()->loadAddress(-1,set.param); + if (Global::instance()->addrCfg()->hasSection("default")) + Global::instance()->loadAddress(-1, set.param); - set.updateData(false); + set.updateData(false); - if(set.exec()==1) - { - Global::instance()->saveAddress(-1,set.param); - Global::instance()->addrCfg()->save(); - } + if (set.exec() == 1) { + Global::instance()->saveAddress(-1, set.param); + Global::instance()->addrCfg()->save(); + } } void Frame::preference() { - prefDialog pref(this); + prefDialog pref(this); - if(pref.exec()==1) - { - Config * pConf= Global::instance()->fileCfg(); - loadPref(pConf); - setUseDock(m_pref.bTray); - } + if (pref.exec() == 1) { + Config * pConf = Global::instance()->fileCfg(); + loadPref(pConf); + setUseDock(m_pref.bTray); + } } void Frame::keySetup() { - keyDialog keyDlg(this); - if(keyDlg.exec()==1) - { - updateKeyToolBar(); - } + keyDialog keyDlg(this); + if (keyDlg.exec() == 1) { + updateKeyToolBar(); + } } void Frame::antiIdle(bool isEnabled) { - wndmgr->activeWindow()->antiIdle(isEnabled); + wndmgr->activeWindow()->antiIdle(isEnabled); } void Frame::autoReply(bool isEnabled) { - wndmgr->activeWindow()->autoReply(isEnabled); + wndmgr->activeWindow()->autoReply(isEnabled); } -void Frame::viewMessages( ) +void Frame::viewMessages() { - wndmgr->activeWindow()->viewMessages(); + wndmgr->activeWindow()->viewMessages(); } void Frame::updateMouse(bool isEnabled) { - wndmgr->activeWindow()->m_bMouse = isEnabled; - m_mouseAction->setChecked(wndmgr->activeWindow()->m_bMouse); + wndmgr->activeWindow()->m_bMouse = isEnabled; + m_mouseAction->setChecked(wndmgr->activeWindow()->m_bMouse); } void Frame::viewImages() { - Image viewer(Global::instance()->pathPic()+"pic/shadow.png", m_pref.strPoolPath, this); - viewer.exec(); + Image viewer(Global::instance()->pathPic() + "pic/shadow.png", m_pref.strPoolPath, this); + viewer.exec(); } void Frame::updateBeep(bool isEnabled) { - wndmgr->activeWindow()->m_bBeep = isEnabled; - m_beepAction->setChecked(wndmgr->activeWindow()->m_bBeep); + wndmgr->activeWindow()->m_bBeep = isEnabled; + m_beepAction->setChecked(wndmgr->activeWindow()->m_bBeep); } void Frame::reconnect(bool isEnabled) { - wndmgr->activeWindow()->m_bReconnect = isEnabled; + wndmgr->activeWindow()->m_bReconnect = isEnabled; } void Frame::runScript() { - wndmgr->activeWindow()->runScript(); + wndmgr->activeWindow()->runScript(); } void Frame::stopScript() { - wndmgr->activeWindow()->stopScript(); + wndmgr->activeWindow()->stopScript(); } void Frame::keyClicked(int id) { - if(wndmgr->activeWindow()==NULL) - return; + if (wndmgr->activeWindow() == NULL) + return; - Config * conf= Global::instance()->fileCfg(); + Config * conf = Global::instance()->fileCfg(); - QString strItem = QString("key%1").arg(id); -// strItem.sprintf("key%d",id); - QString strTmp = conf->getItemValue("key", strItem); + QString strItem = QString("key%1").arg(id); - if(strTmp[0]=='0') // key - { - wndmgr->activeWindow()->externInput(strTmp.mid(1).toLatin1()); - }else if(strTmp[0]=='1') // script - { - wndmgr->activeWindow()->runScriptFile(strTmp.mid(1).toLatin1()); - } - else if(strTmp[0]=='2') // program - { - system((strTmp.mid(1)+" &").toLocal8Bit()); - } + QString strTmp = conf->getItemValue("key", strItem); + + if (strTmp[0] == '0') { // key + wndmgr->activeWindow()->externInput(strTmp.mid(1).toLatin1()); + } else if (strTmp[0] == '1') { // script + wndmgr->activeWindow()->runScriptFile(strTmp.mid(1).toLatin1()); + } else if (strTmp[0] == '2') { // program + system((strTmp.mid(1) + " &").toLocal8Bit()); + } } void Frame::toolBarPosChanged(QToolBar*) { - Config * conf= Global::instance()->fileCfg(); - -// Qt::ToolBarDock dock; - int index; - bool nl; - int extra; - -// if(bar==mdiTools) - { -// getLocation(mdiTools, dock, index, nl, extra); -// conf.setItemValue("global","mainbar",valueToString(mdiTools->isVisible(), (int)dock, index, nl, extra)); - } -// else if(bar==key) - { -// getLocation(key, dock, index, nl, extra); -// conf.setItemValue("global","keybar",valueToString(key->isVisible(), (int)dock, index, nl, extra)); - } -// else if(bar==mdiconnectTools) - { -// getLocation(mdiconnectTools, dock, index, nl, extra); -// conf.setItemValue("global","bbsbar", valueToString(mdiconnectTools->isVisible(), (int)dock, index, nl, extra)); - } + Config * conf = Global::instance()->fileCfg(); - conf->save(); +// Qt::ToolBarDock dock; + int index; + bool nl; + int extra; + +// TODO: Position of the tool bar? + conf->save(); } void Frame::addMainTool() { - mdiTools = addToolBar( "Main ToolBar" ); + mdiTools = addToolBar("Main ToolBar"); - Config * conf= Global::instance()->fileCfg(); - int hide,dock,index,nl,extra; + Config * conf = Global::instance()->fileCfg(); + int hide, dock, index, nl, extra; - QString strTmp = conf->getItemValue("global","mainbar"); - if(!strTmp.isEmpty()) - { - sscanf(strTmp.toLatin1(),"%d %d %d %d %d",&hide,&dock,&index,&nl,&extra); - if(hide==0) - mdiTools->hide(); - } - connectButton = new QToolButton( mdiTools ); - connectButton->setIcon(QPixmap(Global::instance()->pathPic()+"pic/connect.png")); + QString strTmp = conf->getItemValue("global", "mainbar"); + if (!strTmp.isEmpty()) { + sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); + if (hide == 0) + mdiTools->hide(); + } + connectButton = new QToolButton(mdiTools); + connectButton->setIcon(QPixmap(Global::instance()->pathPic() + "pic/connect.png")); - mdiTools->addWidget(connectButton); - connectMenu = new QMenu(this); + mdiTools->addWidget(connectButton); + connectMenu = new QMenu(this); - connect( connectMenu, SIGNAL(aboutToShow()), this, SLOT(popupConnectMenu()) ); - connectButton->setMenu(connectMenu); - connectButton->setPopupMode(QToolButton::InstantPopup); - - mdiTools->addAction( m_quickConnectAction ); - // custom define - key = addToolBar("Custom Key"); - strTmp = conf->getItemValue("global","keybar"); - if(!strTmp.isEmpty()) - { - sscanf(strTmp.toLatin1(),"%d %d %d %d %d",&hide,&dock,&index,&nl,&extra); - if(hide==0) - key->hide(); - } + connect(connectMenu, SIGNAL(aboutToShow()), this, SLOT(popupConnectMenu())); + connectButton->setMenu(connectMenu); + connectButton->setPopupMode(QToolButton::InstantPopup); - // the toolbar - mdiconnectTools = addToolBar( "bbs operations" ); - strTmp = conf->getItemValue("global","bbbar"); - if(!strTmp.isEmpty()) - { - sscanf(strTmp.toLatin1(),"%d %d %d %d %d",&hide,&dock,&index,&nl,&extra); - } + mdiTools->addAction(m_quickConnectAction); + // custom define + key = addToolBar("Custom Key"); + strTmp = conf->getItemValue("global", "keybar"); + if (!strTmp.isEmpty()) { + sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); + if (hide == 0) + key->hide(); + } - mdiconnectTools->addAction(m_disconnectAction); - mdiconnectTools->addSeparator(); + // the toolbar + mdiconnectTools = addToolBar("bbs operations"); + strTmp = conf->getItemValue("global", "bbbar"); + if (!strTmp.isEmpty()) { + sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); + } - mdiconnectTools->addAction(m_copyAction); - mdiconnectTools->addAction(m_pasteAction); - mdiconnectTools->addAction(m_rectAction); - mdiconnectTools->addAction(m_colorCopyAction); - mdiconnectTools->addSeparator(); + mdiconnectTools->addAction(m_disconnectAction); + mdiconnectTools->addSeparator(); - mdiconnectTools->addAction(m_fontAction); - mdiconnectTools->addAction(m_colorAction); - mdiconnectTools->addAction(m_refreshAction); - mdiconnectTools->addSeparator(); - - mdiconnectTools->addAction(m_currentSessionAction); - mdiconnectTools->addSeparator(); + mdiconnectTools->addAction(m_copyAction); + mdiconnectTools->addAction(m_pasteAction); + mdiconnectTools->addAction(m_rectAction); + mdiconnectTools->addAction(m_colorCopyAction); + mdiconnectTools->addSeparator(); - mdiconnectTools->addAction(m_copyArticleAction); - mdiconnectTools->addAction(m_antiIdleAction); - mdiconnectTools->addAction(m_autoReplyAction); - mdiconnectTools->addAction(m_viewMessageAction); - mdiconnectTools->addAction(m_mouseAction); - mdiconnectTools->addAction(m_beepAction); - mdiconnectTools->addAction(m_reconnectAction); + mdiconnectTools->addAction(m_fontAction); + mdiconnectTools->addAction(m_colorAction); + mdiconnectTools->addAction(m_refreshAction); + mdiconnectTools->addSeparator(); + + mdiconnectTools->addAction(m_currentSessionAction); + mdiconnectTools->addSeparator(); + + mdiconnectTools->addAction(m_copyArticleAction); + mdiconnectTools->addAction(m_antiIdleAction); + mdiconnectTools->addAction(m_autoReplyAction); + mdiconnectTools->addAction(m_viewMessageAction); + mdiconnectTools->addAction(m_mouseAction); + mdiconnectTools->addAction(m_beepAction); + mdiconnectTools->addAction(m_reconnectAction); } void Frame::initShortcuts() { - int i = 0; - QShortcut * shortcut = NULL; - QSignalMapper * addrMapper = new QSignalMapper(this); - for (i = 0; i < 9; i++) { - shortcut = new QShortcut(Qt::CTRL+Qt::ALT+0x30+1+i,this); - connect(shortcut, SIGNAL(activated()), addrMapper, SLOT(map())); - addrMapper->setMapping(shortcut, i); - } - connect(addrMapper, SIGNAL(mapped(int)), this, SLOT(connectMenuActivated(int))); - QSignalMapper * windowMapper = new QSignalMapper(this); - for (i = 0; i < 10; i++) { - shortcut = new QShortcut(Qt::ALT+0x30+1+i,this); - connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); - windowMapper->setMapping(shortcut, i); - } - shortcut = new QShortcut(Qt::ALT+Qt::Key_Left, this); - connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); - windowMapper->setMapping(shortcut, 200); - shortcut = new QShortcut(Qt::ALT+Qt::Key_Up, this); - connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); - windowMapper->setMapping(shortcut, 200); - shortcut = new QShortcut(Qt::ALT+Qt::Key_Right, this); - connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); - windowMapper->setMapping(shortcut, 201); - shortcut = new QShortcut(Qt::ALT+Qt::Key_Down, this); - connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); - windowMapper->setMapping(shortcut, 201); - connect(windowMapper, SIGNAL(mapped(int)), this, SLOT(switchWin(int))); + int i = 0; + QShortcut * shortcut = NULL; + QSignalMapper * addrMapper = new QSignalMapper(this); + for (i = 0; i < 9; i++) { + shortcut = new QShortcut(Qt::CTRL + Qt::ALT + 0x30 + 1 + i, this); + connect(shortcut, SIGNAL(activated()), addrMapper, SLOT(map())); + addrMapper->setMapping(shortcut, i); + } + connect(addrMapper, SIGNAL(mapped(int)), this, SLOT(connectMenuActivated(int))); + QSignalMapper * windowMapper = new QSignalMapper(this); + for (i = 0; i < 10; i++) { + shortcut = new QShortcut(Qt::ALT + 0x30 + 1 + i, this); + connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); + windowMapper->setMapping(shortcut, i); + } + shortcut = new QShortcut(Qt::ALT + Qt::Key_Left, this); + connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); + windowMapper->setMapping(shortcut, 200); + shortcut = new QShortcut(Qt::ALT + Qt::Key_Up, this); + connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); + windowMapper->setMapping(shortcut, 200); + shortcut = new QShortcut(Qt::ALT + Qt::Key_Right, this); + connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); + windowMapper->setMapping(shortcut, 201); + shortcut = new QShortcut(Qt::ALT + Qt::Key_Down, this); + connect(shortcut, SIGNAL(activated()), windowMapper, SLOT(map())); + windowMapper->setMapping(shortcut, 201); + connect(windowMapper, SIGNAL(mapped(int)), this, SLOT(switchWin(int))); } void Frame::initActions() { - QString pathLib = Global::instance()->pathLib(); - m_connectAction = new QAction(QPixmap(pathLib+"pic/connect.png"), tr("&Connect"),this); - m_disconnectAction = new QAction(QPixmap(pathLib+"pic/disconnect.png"), tr("&Disconnect"), this); - m_addressAction = new QAction(QPixmap(pathLib+"pic/addr.png"), tr("&Address book"), this); - m_addressAction->setShortcut(Qt::Key_F2); - m_quickConnectAction = new QAction(QPixmap(pathLib+"pic/quick.png"), tr("&Quick login"),this); - m_quickConnectAction->setShortcut(Qt::Key_F3); - m_exitAction = new QAction(tr("&Exit"), this); + QString pathLib = Global::instance()->pathLib(); + m_connectAction = new QAction(QPixmap(pathLib + "pic/connect.png"), tr("&Connect"), this); + m_disconnectAction = new QAction(QPixmap(pathLib + "pic/disconnect.png"), tr("&Disconnect"), this); + m_addressAction = new QAction(QPixmap(pathLib + "pic/addr.png"), tr("&Address book"), this); + m_addressAction->setShortcut(Qt::Key_F2); + m_quickConnectAction = new QAction(QPixmap(pathLib + "pic/quick.png"), tr("&Quick login"), this); + m_quickConnectAction->setShortcut(Qt::Key_F3); + m_exitAction = new QAction(tr("&Exit"), this); - m_copyAction = new QAction(QPixmap(pathLib+"pic/copy.png"), tr("&Copy"), this); - m_copyAction->setShortcut(Qt::CTRL+Qt::Key_Insert); - m_pasteAction = new QAction(QPixmap(pathLib+"pic/paste.png"),tr("&Paste"), this); - m_pasteAction->setShortcut(Qt::SHIFT+Qt::Key_Insert); - m_colorCopyAction = new QAction(QPixmap(pathLib+"pic/color-copy.png"), tr("C&opy with color"), this); - m_colorCopyAction->setCheckable(true); - m_rectAction = new QAction(QPixmap(pathLib+"pic/rect.png"), tr("&Rectangle select"), this); - m_rectAction->setCheckable(true); - m_autoCopyAction = new QAction(tr("Auto copy &select"), this); - m_autoCopyAction->setCheckable(true); - m_wwrapAction = new QAction(tr("P&aste with wordwrap"), this); - m_wwrapAction->setCheckable(true); + m_copyAction = new QAction(QPixmap(pathLib + "pic/copy.png"), tr("&Copy"), this); + m_copyAction->setShortcut(Qt::CTRL + Qt::Key_Insert); + m_pasteAction = new QAction(QPixmap(pathLib + "pic/paste.png"), tr("&Paste"), this); + m_pasteAction->setShortcut(Qt::SHIFT + Qt::Key_Insert); + m_colorCopyAction = new QAction(QPixmap(pathLib + "pic/color-copy.png"), tr("C&opy with color"), this); + m_colorCopyAction->setCheckable(true); + m_rectAction = new QAction(QPixmap(pathLib + "pic/rect.png"), tr("&Rectangle select"), this); + m_rectAction->setCheckable(true); + m_autoCopyAction = new QAction(tr("Auto copy &select"), this); + m_autoCopyAction->setCheckable(true); + m_wwrapAction = new QAction(tr("P&aste with wordwrap"), this); + m_wwrapAction->setCheckable(true); - QActionGroup * escapeGroup = new QActionGroup(this); - m_noescAction = new QAction(tr("&None"), this); - m_noescAction->setObjectName("noesc"); - m_noescAction->setCheckable(true); - m_escescAction = new QAction(tr("&ESC ESC ["), this); - m_escescAction->setObjectName("escesc"); - m_escescAction->setCheckable(true); - m_uescAction = new QAction(tr("Ctrl+&U ["), this); - m_uescAction->setObjectName("uesc"); - m_uescAction->setCheckable(true); - m_customescAction = new QAction(tr("&Custom..."), this); - m_customescAction->setObjectName("custom"); - m_customescAction->setCheckable(true); - escapeGroup->addAction(m_noescAction); - escapeGroup->addAction(m_escescAction); - escapeGroup->addAction(m_uescAction); - escapeGroup->addAction(m_customescAction); + QActionGroup * escapeGroup = new QActionGroup(this); + m_noescAction = new QAction(tr("&None"), this); + m_noescAction->setObjectName("noesc"); + m_noescAction->setCheckable(true); + m_escescAction = new QAction(tr("&ESC ESC ["), this); + m_escescAction->setObjectName("escesc"); + m_escescAction->setCheckable(true); + m_uescAction = new QAction(tr("Ctrl+&U ["), this); + m_uescAction->setObjectName("uesc"); + m_uescAction->setCheckable(true); + m_customescAction = new QAction(tr("&Custom..."), this); + m_customescAction->setObjectName("custom"); + m_customescAction->setCheckable(true); + escapeGroup->addAction(m_noescAction); + escapeGroup->addAction(m_escescAction); + escapeGroup->addAction(m_uescAction); + escapeGroup->addAction(m_customescAction); - QActionGroup * codecGroup = new QActionGroup(this); - m_GBKAction = new QAction(tr("&GBK"), this); - m_GBKAction->setObjectName("GBK"); - m_GBKAction->setCheckable(true); - m_BIG5Action = new QAction(tr("&Big5"), this); - m_BIG5Action->setObjectName("Big5"); - m_BIG5Action->setCheckable(true); - codecGroup->addAction(m_GBKAction); - codecGroup->addAction(m_BIG5Action); + QActionGroup * codecGroup = new QActionGroup(this); + m_GBKAction = new QAction(tr("&GBK"), this); + m_GBKAction->setObjectName("GBK"); + m_GBKAction->setCheckable(true); + m_BIG5Action = new QAction(tr("&Big5"), this); + m_BIG5Action->setObjectName("Big5"); + m_BIG5Action->setCheckable(true); + codecGroup->addAction(m_GBKAction); + codecGroup->addAction(m_BIG5Action); - m_fontAction = new QAction(QPixmap(pathLib+"pic/fonts.png"), tr("&Font"), this); - m_colorAction = new QAction(QPixmap(pathLib+"pic/color.png"), tr("&Color"), this); - m_refreshAction = new QAction(QPixmap(pathLib+"pic/refresh.png"), tr("&Refresh"), this); - m_refreshAction->setShortcut(Qt::Key_F5); + m_fontAction = new QAction(QPixmap(pathLib + "pic/fonts.png"), tr("&Font"), this); + m_colorAction = new QAction(QPixmap(pathLib + "pic/color.png"), tr("&Color"), this); + m_refreshAction = new QAction(QPixmap(pathLib + "pic/refresh.png"), tr("&Refresh"), this); + m_refreshAction->setShortcut(Qt::Key_F5); - QActionGroup * langGroup = new QActionGroup(this); - m_engAction = new QAction(tr("&English"),this); - m_engAction->setObjectName("eng"); - m_engAction->setCheckable(true); - m_chsAction = new QAction(tr("&Simplified Chinese"),this); - m_chsAction->setObjectName("chs"); - m_chsAction->setCheckable(true); - m_chtAction = new QAction(tr("&Traditional Chinese"),this); - m_chtAction->setObjectName("cht"); - m_chtAction->setCheckable(true); - langGroup->addAction(m_engAction); - langGroup->addAction(m_chsAction); - langGroup->addAction(m_chtAction); + QActionGroup * langGroup = new QActionGroup(this); + m_engAction = new QAction(tr("&English"), this); + m_engAction->setObjectName("eng"); + m_engAction->setCheckable(true); + m_chsAction = new QAction(tr("&Simplified Chinese"), this); + m_chsAction->setObjectName("chs"); + m_chsAction->setCheckable(true); + m_chtAction = new QAction(tr("&Traditional Chinese"), this); + m_chtAction->setObjectName("cht"); + m_chtAction->setCheckable(true); + langGroup->addAction(m_engAction); + langGroup->addAction(m_chsAction); + langGroup->addAction(m_chtAction); - m_uiFontAction = new QAction(tr("&UI font"), this); - m_fullAction = new QAction(tr("&Fullscreen"), this); - m_fullAction->setShortcut(Qt::Key_F6); - addAction(m_fullAction); - m_bossAction = new QAction(tr("Boss &Color"), this); - m_bossAction->setShortcut(Qt::Key_F12); + m_uiFontAction = new QAction(tr("&UI font"), this); + m_fullAction = new QAction(tr("&Fullscreen"), this); + m_fullAction->setShortcut(Qt::Key_F6); + addAction(m_fullAction); + m_bossAction = new QAction(tr("Boss &Color"), this); + m_bossAction->setShortcut(Qt::Key_F12); - QActionGroup * scrollGroup = new QActionGroup(this); - m_scrollHideAction = new QAction(tr("&Hide"), this); - m_scrollHideAction->setObjectName("Hide"); - m_scrollHideAction->setCheckable(true); - m_scrollLeftAction = new QAction(tr("&Left"), this); - m_scrollLeftAction->setObjectName("Left"); - m_scrollLeftAction->setCheckable(true); - m_scrollRightAction = new QAction(tr("&Right"), this); - m_scrollRightAction->setObjectName("Right"); - m_scrollRightAction->setCheckable(true); - scrollGroup->addAction(m_scrollHideAction); - scrollGroup->addAction(m_scrollLeftAction); - scrollGroup->addAction(m_scrollRightAction); + QActionGroup * scrollGroup = new QActionGroup(this); + m_scrollHideAction = new QAction(tr("&Hide"), this); + m_scrollHideAction->setObjectName("Hide"); + m_scrollHideAction->setCheckable(true); + m_scrollLeftAction = new QAction(tr("&Left"), this); + m_scrollLeftAction->setObjectName("Left"); + m_scrollLeftAction->setCheckable(true); + m_scrollRightAction = new QAction(tr("&Right"), this); + m_scrollRightAction->setObjectName("Right"); + m_scrollRightAction->setCheckable(true); + scrollGroup->addAction(m_scrollHideAction); + scrollGroup->addAction(m_scrollLeftAction); + scrollGroup->addAction(m_scrollRightAction); - m_statusAction = new QAction(tr("Status &Bar"), this); - m_statusAction->setCheckable(true); - m_switchAction = new QAction(tr("S&witch Bar"), this); - m_switchAction->setCheckable(true); + m_statusAction = new QAction(tr("Status &Bar"), this); + m_statusAction->setCheckable(true); + m_switchAction = new QAction(tr("S&witch Bar"), this); + m_switchAction->setCheckable(true); - m_currentSessionAction = new QAction(QPixmap(pathLib+"pic/pref.png"), tr("&Setting for currrent session"), this); - m_defaultAction = new QAction(tr("&Default setting"), this); - m_prefAction = new QAction(tr("&Preference"), this); + m_currentSessionAction = new QAction(QPixmap(pathLib + "pic/pref.png"), tr("&Setting for currrent session"), this); + m_defaultAction = new QAction(tr("&Default setting"), this); + m_prefAction = new QAction(tr("&Preference"), this); - m_copyArticleAction = new QAction(QPixmap(pathLib+"pic/article.png"), tr("&Copy article"), this); - m_copyArticleAction->setShortcut(Qt::Key_F9); - m_antiIdleAction = new QAction(QPixmap(pathLib+"pic/anti-idle.png"), tr("Anti &idle"), this); - m_antiIdleAction->setCheckable(true); - m_autoReplyAction = new QAction(QPixmap(pathLib+"pic/auto-reply.png"), tr("Auto &reply"), this); - m_autoReplyAction->setCheckable(true); - m_viewMessageAction = new QAction(QPixmap(pathLib+"pic/message.png"), tr("&View messages"), this); - m_viewMessageAction->setShortcut(Qt::Key_F10); - m_beepAction = new QAction(QPixmap(pathLib+"pic/sound.png"), tr("&Beep "), this); - m_beepAction->setCheckable(true); - m_mouseAction = new QAction(QPixmap(pathLib+"pic/mouse.png"), tr("&Mouse support"), this); - m_mouseAction->setCheckable(true); - m_viewImageAction = new QAction(tr("&Image viewer"), this); + m_copyArticleAction = new QAction(QPixmap(pathLib + "pic/article.png"), tr("&Copy article"), this); + m_copyArticleAction->setShortcut(Qt::Key_F9); + m_antiIdleAction = new QAction(QPixmap(pathLib + "pic/anti-idle.png"), tr("Anti &idle"), this); + m_antiIdleAction->setCheckable(true); + m_autoReplyAction = new QAction(QPixmap(pathLib + "pic/auto-reply.png"), tr("Auto &reply"), this); + m_autoReplyAction->setCheckable(true); + m_viewMessageAction = new QAction(QPixmap(pathLib + "pic/message.png"), tr("&View messages"), this); + m_viewMessageAction->setShortcut(Qt::Key_F10); + m_beepAction = new QAction(QPixmap(pathLib + "pic/sound.png"), tr("&Beep "), this); + m_beepAction->setCheckable(true); + m_mouseAction = new QAction(QPixmap(pathLib + "pic/mouse.png"), tr("&Mouse support"), this); + m_mouseAction->setCheckable(true); + m_viewImageAction = new QAction(tr("&Image viewer"), this); - m_scriptRunAction = new QAction(tr("&Run..."), this); - m_scriptRunAction->setS... [truncated message content] |
From: <hep...@us...> - 2008-11-18 11:25:19
|
Revision: 520 http://qterm.svn.sourceforge.net/qterm/?rev=520&view=rev Author: hephooey Date: 2008-11-18 11:25:16 +0000 (Tue, 18 Nov 2008) Log Message: ----------- setUseDock->setUseTray Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:25:08 UTC (rev 519) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:25:16 UTC (rev 520) @@ -218,7 +218,7 @@ loadPref(conf); - setUseDock(m_pref.bTray); + setUseTray(m_pref.bTray); } void Frame::loadPref(Config * conf) @@ -361,7 +361,7 @@ Global::instance()->clearDir(m_pref.strPoolPath + "shadow-cache/"); } - setUseDock(false); + setUseTray(false); qApp->quit(); } @@ -543,7 +543,7 @@ Global::instance()->clearDir(m_pref.strPoolPath + "shadow-cache/"); } - setUseDock(false); + setUseTray(false); clse->accept(); @@ -775,7 +775,7 @@ if (pref.exec() == 1) { Config * pConf = Global::instance()->fileCfg(); loadPref(pConf); - setUseDock(m_pref.bTray); + setUseTray(m_pref.bTray); } } @@ -1378,7 +1378,7 @@ return idAction; } -void Frame::setUseDock(bool use) +void Frame::setUseTray(bool use) { if (use == false) { if (tray) { Modified: trunk/qterm-qt4/src/qtermframe.h =================================================================== --- trunk/qterm-qt4/src/qtermframe.h 2008-11-18 11:25:08 UTC (rev 519) +++ trunk/qterm-qt4/src/qtermframe.h 2008-11-18 11:25:16 UTC (rev 520) @@ -245,7 +245,7 @@ QString valueToString(bool, int, int, bool, int); QAction * insertThemeItem(const QString &); - void setUseDock(bool); + void setUseTray(bool); private: static Frame * s_instance; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-18 11:26:08
|
Revision: 524 http://qterm.svn.sourceforge.net/qterm/?rev=524&view=rev Author: hephooey Date: 2008-11-18 11:26:04 +0000 (Tue, 18 Nov 2008) Log Message: ----------- WIP: factor out the non-UI code from Frame class Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermglobal.h trunk/qterm-qt4/src/qtermhttp.cpp trunk/qterm-qt4/src/qtermscreen.cpp trunk/qterm-qt4/src/qtermwindow.cpp trunk/qterm-qt4/src/qtermzmodem.cpp Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:25:46 UTC (rev 523) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:26:04 UTC (rev 524) @@ -2,7 +2,7 @@ FILENAME: qtermframe.cpp REVISION: 2001.10.4 first created. -AUTHOR: kingson fiasco +AUTHOR: kingson fiasco hooey *******************************************************************************/ /******************************************************************************* NOTE @@ -132,6 +132,7 @@ } //initialize setting from qterm.cfg +// TODO: separate config reading and UI setting void Frame::iniSetting() { Config * conf = Global::instance()->fileCfg(); @@ -143,11 +144,11 @@ // settings.setValue("pos", pos()); strTmp = conf->getItemValue("global", "fullscreen"); if (strTmp == "1") { - m_bFullScreen = true; + Global::instance()->setFullScreen(true); m_fullAction->setChecked(true); showFullScreen(); } else { - m_bFullScreen = false; + Global::instance()->setFullScreen(false); //window size strTmp = conf->getItemValue("global", "max"); if (strTmp == "1") @@ -180,90 +181,51 @@ m_engAction->setChecked(true); m_noescAction->setChecked(true); - m_strEscape = ""; + Global::instance()->setEscapeString(""); + //m_strEscape = ""; strTmp = conf->getItemValue("global", "clipcodec"); if (strTmp == "0") { - m_nClipCodec = 0; + Global::instance()->setClipCodec(Global::GBK); m_GBKAction->setChecked(true); } else { - m_nClipCodec = 1; + Global::instance()->setClipCodec(Global::Big5); m_BIG5Action->setChecked(true); } strTmp = conf->getItemValue("global", "vscrollpos"); if (strTmp == "0") { - m_nScrollPos = 0; + Global::instance()->setScrollPosition(Global::Hide); m_scrollHideAction->setChecked(true); } else if (strTmp == "1") { - m_nScrollPos = 1; + Global::instance()->setScrollPosition(Global::Left); m_scrollLeftAction->setChecked(true); } else { - m_nScrollPos = 2; + Global::instance()->setScrollPosition(Global::Right); m_scrollRightAction->setChecked(true); } strTmp = conf->getItemValue("global", "statusbar"); - m_bStatusBar = (strTmp != "0"); - m_statusAction->setChecked(m_bStatusBar); + //m_bStatusBar = (strTmp != "0"); + Global::instance()->setStatusBar(strTmp != "0"); + m_statusAction->setChecked(Global::instance()->showStatusBar()); strTmp = conf->getItemValue("global", "switchbar"); - m_bSwitchBar = (strTmp != "0"); - m_switchAction->setChecked(m_bSwitchBar); - if (m_bSwitchBar) + Global::instance()->setSwitchBar((strTmp != "0")); + m_switchAction->setChecked(Global::instance()->showSwitchBar()); + if (Global::instance()->showSwitchBar()) statusBar()->show(); else statusBar()->hide(); - m_bBossColor = false; + Global::instance()->setBossColor(false); - loadPref(conf); + Global::instance()->loadPrefence(); - setUseTray(m_pref.bTray); + setUseTray(Global::instance()->m_pref.bTray); } -void Frame::loadPref(Config * conf) -{ - QString strTmp; - strTmp = conf->getItemValue("preference", "xim"); - m_pref.nXIM = strTmp.toInt(); - strTmp = conf->getItemValue("preference", "wordwrap"); - m_pref.nWordWrap = strTmp.toInt(); - strTmp = conf->getItemValue("preference", "wheel"); - m_pref.bWheel = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "url"); - m_pref.bUrl = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "blinktab"); - m_pref.bBlinkTab = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "warn"); - m_pref.bWarn = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "beep"); - m_pref.nBeep = strTmp.toInt(); - m_pref.strWave = conf->getItemValue("preference", "wavefile"); - strTmp = conf->getItemValue("preference", "http"); - m_pref.strHttp = strTmp; - strTmp = conf->getItemValue("preference", "antialias"); - m_pref.bAA = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "tray"); - m_pref.bTray = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "externalplayer"); - m_pref.strPlayer = strTmp; - - strTmp = conf->getItemValue("preference", "clearpool"); - m_pref.bClearPool = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "pool"); - m_pref.strPoolPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "pool/" : strTmp; - if (m_pref.strPoolPath.right(1) != "/") - m_pref.strPoolPath.append('/'); - strTmp = conf->getItemValue("preference", "zmodem"); - m_pref.strZmPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "zmodem/" : strTmp; - if (m_pref.strZmPath.right(1) != "/") - m_pref.strZmPath.append('/'); - strTmp = conf->getItemValue("preference", "image"); - m_pref.strImageViewer = strTmp; -} - //save current setting to qterm.cfg void Frame::saveSetting() { @@ -290,7 +252,7 @@ conf->setItemValue("global", "max", "0"); } - if (m_bFullScreen) + if (Global::instance()->isFullScreen()) conf->setItemValue("global", "fullscreen", "1"); else conf->setItemValue("global", "fullscreen", "0"); @@ -316,14 +278,15 @@ (int)dock, index, nl == 1 ? true : false, extra)); - strTmp.setNum(m_nClipCodec); + // Should we convert the numbers to strings like "GBK" and "Big5"; + strTmp.setNum(Global::instance()->clipCodec()); conf->setItemValue("global", "clipcodec", strTmp); - strTmp.setNum(m_nScrollPos); + strTmp.setNum(Global::instance()->scrollPosition()); conf->setItemValue("global", "vscrollpos", strTmp); - conf->setItemValue("global", "statusbar", m_bStatusBar ? "1" : "0"); - conf->setItemValue("global", "switchbar", m_bSwitchBar ? "1" : "0"); + conf->setItemValue("global", "statusbar", Global::instance()->showStatusBar() ? "1" : "0"); + conf->setItemValue("global", "switchbar", Global::instance()->showSwitchBar() ? "1" : "0"); conf->save(); } @@ -361,10 +324,10 @@ saveSetting(); // clear zmodem and pool if needed - if (m_pref.bClearPool) { - Global::instance()->clearDir(m_pref.strZmPath); - Global::instance()->clearDir(m_pref.strPoolPath); - Global::instance()->clearDir(m_pref.strPoolPath + "shadow-cache/"); + if (Global::instance()->m_pref.bClearPool) { + Global::instance()->clearDir(Global::instance()->m_pref.strZmPath); + Global::instance()->clearDir(Global::instance()->m_pref.strPoolPath); + Global::instance()->clearDir(Global::instance()->m_pref.strPoolPath + "shadow-cache/"); } setUseTray(false); @@ -411,7 +374,7 @@ //slot Help->Homepage void Frame::homepage() { - QString strCmd = m_pref.strHttp; + QString strCmd = Global::instance()->m_pref.strHttp; QString strUrl = "http://www.qterm.org"; if (strCmd.indexOf("%L") == -1) @@ -526,7 +489,7 @@ for (int i = 0; i < int(windows.count()); ++i) { if (((Window *)windows.at(i))->isConnected()) { - if (m_pref.bTray) { + if (Global::instance()->m_pref.bTray) { trayHide(); clse->ignore(); return; @@ -543,10 +506,11 @@ saveSetting(); // clear zmodem and pool if needed - if (m_pref.bClearPool) { - Global::instance()->clearDir(m_pref.strZmPath); - Global::instance()->clearDir(m_pref.strPoolPath); - Global::instance()->clearDir(m_pref.strPoolPath + "shadow-cache/"); + // FIXME: cleanup the code + if (Global::instance()->m_pref.bClearPool) { + Global::instance()->clearDir(Global::instance()->m_pref.strZmPath); + Global::instance()->clearDir(Global::instance()->m_pref.strPoolPath); + Global::instance()->clearDir(Global::instance()->m_pref.strPoolPath + "shadow-cache/"); } setUseTray(false); @@ -615,16 +579,16 @@ void Frame::updateESC(QAction * action) { if (action->objectName() == "actionNoESC") { - m_strEscape = ""; + Global::instance()->setEscapeString(""); } else if (action->objectName() == "actionESCESC") { - m_strEscape = "^[^[["; + Global::instance()->setEscapeString("^[^[["); } else if (action->objectName() == "actionUESC") { - m_strEscape = "^u["; + Global::instance()->setEscapeString("^u["); } else if (action->objectName() == "actionCustomESC") { bool ok; - QString strEsc = QInputDialog::getText(this, "define escape", "scape string *[", QLineEdit::Normal, m_strEscape , &ok); + QString strEsc = QInputDialog::getText(this, "define escape", "scape string *[", QLineEdit::Normal, Global::instance()->escapeString(), &ok); if (ok) - m_strEscape = strEsc; + Global::instance()->setEscapeString(strEsc); } else { qDebug("updateESC: should not be here"); } @@ -633,9 +597,9 @@ void Frame::updateCodec(QAction * action) { if (action->objectName() == "actionGBK") { - m_nClipCodec = 0; + Global::instance()->setClipCodec(Global::GBK); } else if (action->objectName() == "actionBig5") { - m_nClipCodec = 1; + Global::instance()->setClipCodec(Global::Big5); } else { qDebug("updateCodec: should not be here"); } @@ -661,7 +625,7 @@ bool ok; QFont font = QFontDialog::getFont(&ok, qApp->font()); - if (m_pref.bAA) + if (Global::instance()->m_pref.bAA) font.setStyleStrategy(QFont::PreferAntialias); if (ok == true) { @@ -671,9 +635,10 @@ void Frame::fullscreen() { - m_bFullScreen = ! m_bFullScreen; + bool tmp = ! Global::instance()->isFullScreen(); + Global::instance()->setFullScreen(tmp); - if (m_bFullScreen) { + if (tmp) { //TODO: add an item to the popup menu so we can go back to normal without touch the keyboard menuBar()->hide(); mdiTools->hide(); @@ -693,17 +658,18 @@ showNormal(); } - m_fullAction->setChecked(m_bFullScreen); + m_fullAction->setChecked(tmp); } void Frame::bosscolor() { - m_bBossColor = !m_bBossColor; + bool tmp = !Global::instance()->isBossColor(); + Global::instance()->setBossColor(tmp); emit bossColor(); - m_bossAction->setChecked(m_bBossColor); + m_bossAction->setChecked(tmp); } void Frame::initThemesMenu() @@ -727,11 +693,11 @@ void Frame::updateScroll(QAction * action) { if (action->objectName() == "actionHide") { - m_nScrollPos = 0; + Global::instance()->setScrollPosition(Global::Hide); } else if (action->objectName() == "actionLeft") { - m_nScrollPos = 1; + Global::instance()->setScrollPosition(Global::Left); } else if (action->objectName() == "actionRight") { - m_nScrollPos = 2; + Global::instance()->setScrollPosition(Global::Right); } else { qDebug("updateScroll: should not be here"); } @@ -740,9 +706,9 @@ void Frame::updateSwitchBar(bool isEnabled) { - m_bSwitchBar = isEnabled; + Global::instance()->setSwitchBar(isEnabled); - if (m_bSwitchBar) + if (Global::instance()->showSwitchBar()) statusBar()->show(); else statusBar()->hide(); @@ -750,9 +716,9 @@ void Frame::updateStatusBar(bool isEnabled) { - m_bStatusBar = isEnabled; + Global::instance()->setStatusBar(isEnabled); - emit statusBarChanged(m_bStatusBar); + emit statusBarChanged(isEnabled); } void Frame::setting() @@ -779,9 +745,8 @@ prefDialog pref(this); if (pref.exec() == 1) { - Config * pConf = Global::instance()->fileCfg(); - loadPref(pConf); - setUseTray(m_pref.bTray); + Global::instance()->loadPrefence(); + setUseTray(Global::instance()->m_pref.bTray); } } @@ -817,7 +782,7 @@ void Frame::viewImages() { - Image viewer(Global::instance()->pathPic() + "pic/shadow.png", m_pref.strPoolPath, this); + Image viewer(Global::instance()->pathPic() + "pic/shadow.png", Global::instance()->m_pref.strPoolPath, this); viewer.exec(); } @@ -1069,7 +1034,7 @@ m_bossAction->setShortcut(Qt::Key_F12); QActionGroup * scrollGroup = new QActionGroup(this); - m_scrollHideAction = new QAction(tr("&actionHide"), this); + m_scrollHideAction = new QAction(tr("&Hide"), this); m_scrollHideAction->setObjectName("actionHide"); m_scrollHideAction->setCheckable(true); m_scrollLeftAction = new QAction(tr("&Left"), this); @@ -1315,7 +1280,7 @@ m_wwrapAction->setChecked(window->m_bWordWrap); - m_fullAction->setChecked(m_bFullScreen); + m_fullAction->setChecked(Global::instance()->isFullScreen()); m_antiIdleAction->setChecked(window->m_bAntiIdle); m_autoReplyAction->setChecked(window->m_bAutoReply); Modified: trunk/qterm-qt4/src/qtermframe.h =================================================================== --- trunk/qterm-qt4/src/qtermframe.h 2008-11-18 11:25:46 UTC (rev 523) +++ trunk/qterm-qt4/src/qtermframe.h 2008-11-18 11:26:04 UTC (rev 524) @@ -27,26 +27,6 @@ class Param; class Config; -struct Pref { - int nXIM; // 0--GBK 1--BIG5 - int nWordWrap; - bool bWheel; - bool bWarn; - bool bBlinkTab; - QString strHttp; - int nBeep; - QString strWave; - QString strPlayer; - bool bUrl; - bool bAutoCopy; - bool bAA; - bool bTray; - bool bClearPool; - QString strZmPath; - QString strPoolPath; - QString strImageViewer; -}; - class Frame : public QMainWindow { Q_OBJECT @@ -134,17 +114,6 @@ QTabBar *tabBar; WndMgr * wndmgr; - Pref m_pref; - bool m_bBossColor; - - QString m_strEscape; - - int m_nClipCodec; // 0--GBK 1--BIG5 - - bool m_bStatusBar; - - int m_nScrollPos; // 0--hide 1--LEFT 2--RIGHT - QMdiArea * m_MdiArea; protected: //variables @@ -222,8 +191,8 @@ QMenuBar * mainMenu; QToolBar *mdiconnectTools, *mdiTools; - bool m_bFullScreen; - bool m_bSwitchBar; +// bool m_bFullScreen; +// bool m_bSwitchBar; QSystemTrayIcon *tray; QMenu *trayMenu; @@ -235,7 +204,7 @@ void iniSetting(); void initActions(); void initShortcuts(); - void loadPref(Config *); + //void loadPref(Config *); void saveSetting(); void addMainMenu(); Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-18 11:25:46 UTC (rev 523) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-18 11:26:04 UTC (rev 524) @@ -305,6 +305,47 @@ } +void Global::loadPrefence() { + Config * conf = Global::instance()->fileCfg(); + QString strTmp; + strTmp = conf->getItemValue("preference", "xim"); + m_pref.nXIM = strTmp.toInt()==0 ? GBK : Big5; + strTmp = conf->getItemValue("preference", "wordwrap"); + m_pref.nWordWrap = strTmp.toInt(); + strTmp = conf->getItemValue("preference", "wheel"); + m_pref.bWheel = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "url"); + m_pref.bUrl = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "blinktab"); + m_pref.bBlinkTab = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "warn"); + m_pref.bWarn = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "beep"); + m_pref.nBeep = strTmp.toInt(); + m_pref.strWave = conf->getItemValue("preference", "wavefile"); + strTmp = conf->getItemValue("preference", "http"); + m_pref.strHttp = strTmp; + strTmp = conf->getItemValue("preference", "antialias"); + m_pref.bAA = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "tray"); + m_pref.bTray = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "externalplayer"); + m_pref.strPlayer = strTmp; + + strTmp = conf->getItemValue("preference", "clearpool"); + m_pref.bClearPool = (strTmp != "0"); + strTmp = conf->getItemValue("preference", "pool"); + m_pref.strPoolPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "pool/" : strTmp; + if (m_pref.strPoolPath.right(1) != "/") + m_pref.strPoolPath.append('/'); + strTmp = conf->getItemValue("preference", "zmodem"); + m_pref.strZmPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "zmodem/" : strTmp; + if (m_pref.strZmPath.right(1) != "/") + m_pref.strZmPath.append('/'); + strTmp = conf->getItemValue("preference", "image"); + m_pref.strImageViewer = strTmp; +} + QString Global::getOpenFileName(const QString & filter, QWidget * widget) { QString path = m_config->getItemValue("global","openfiledialog"); @@ -552,5 +593,60 @@ } return true; } +bool Global::isBossColor() const { + return m_bossColor; +} +const QString & Global::escapeString() const { + return m_escape; +} + +Global::Codec Global::clipCodec() const { + return m_clipCodec; +} + +bool Global::showStatusBar() const { + return m_statusBar; +} + +Global::Position Global::scrollPosition() const { + return m_scrollPos; +} + +bool Global::isFullScreen() const { + return m_fullScreen; +} + +bool Global::showSwitchBar() const { + return m_switchBar; +} + +void Global::setClipCodec(Global::Codec codec) { + m_clipCodec = codec; +} + +void Global::setEscapeString(const QString & escapeString) { + m_escape = escapeString; +} + +void Global::setScrollPosition(Global::Position position) { + m_scrollPos = position; +} + +void Global::setStatusBar(bool isShow) { + m_statusBar = isShow; +} + +void Global::setBossColor(bool isBossColor) { + m_bossColor = isBossColor; +} + +void Global::setFullScreen(bool isFullscreen) { + m_fullScreen = isFullscreen; +} + +void Global::setSwitchBar(bool isShow) { + m_switchBar = isShow; +} + } // namespace QTerm Modified: trunk/qterm-qt4/src/qtermglobal.h =================================================================== --- trunk/qterm-qt4/src/qtermglobal.h 2008-11-18 11:25:46 UTC (rev 523) +++ trunk/qterm-qt4/src/qtermglobal.h 2008-11-18 11:26:04 UTC (rev 524) @@ -23,10 +23,33 @@ class Global { public: + enum Codec { + GBK, + Big5 + }; enum Status { INIT_OK, INIT_ERROR }; + struct Pref { + Codec nXIM; + int nWordWrap; + bool bWheel; + bool bWarn; + bool bBlinkTab; + QString strHttp; + int nBeep; + QString strWave; + QString strPlayer; + bool bUrl; + bool bAutoCopy; + bool bAA; + bool bTray; + bool bClearPool; + QString strZmPath; + QString strPoolPath; + QString strImageViewer; + }; static Global * instance(); Config * fileCfg(); Config * addrCfg(); @@ -40,7 +63,25 @@ QString getOpenFileName(const QString & filter, QWidget * widget); QString getSaveFileName(const QString & filename, QWidget * widget); bool isOK(); + Pref m_pref; + void loadPrefence(); + enum Position {Hide, Left, Right}; + bool isBossColor() const; + const QString & escapeString() const; + Codec clipCodec() const; + bool showStatusBar() const; + Position scrollPosition() const; + bool isFullScreen() const; + bool showSwitchBar() const; + void setClipCodec(Codec codecId); + void setEscapeString(const QString & escapeString); + void setScrollPosition(Position position); + void setStatusBar(bool isShow); //Better name? + void setBossColor(bool isBossColor); + void setFullScreen(bool isFullscreen); + void setSwitchBar(bool isShow); + private: Global(); static Global* m_Instance; @@ -56,6 +97,13 @@ Config * m_config; Config * m_address; Status m_status; + bool m_bossColor; + QString m_escape; + Codec m_clipCodec; + bool m_statusBar; + Position m_scrollPos; + bool m_fullScreen; + bool m_switchBar; }; Modified: trunk/qterm-qt4/src/qtermhttp.cpp =================================================================== --- trunk/qterm-qt4/src/qtermhttp.cpp 2008-11-18 11:25:46 UTC (rev 523) +++ trunk/qterm-qt4/src/qtermhttp.cpp 2008-11-18 11:26:04 UTC (rev 524) @@ -111,7 +111,7 @@ if(m_bPreview) { - QString strPool = Frame::instance()->m_pref.strPoolPath; + QString strPool = Global::instance()->m_pref.strPoolPath; m_strHttpFile = strPool + m_strHttpFile; @@ -208,7 +208,7 @@ } if(m_bPreview) { - QString strPool = Frame::instance()->m_pref.strPoolPath; + QString strPool = Global::instance()->m_pref.strPoolPath; previewImage(m_strHttpFile); QFileInfo fi = QFileInfo(m_strHttpFile); ImageViewer::genThumb(Global::instance()->pathPic()+"pic/shadow.png", strPool, fi.fileName()); Modified: trunk/qterm-qt4/src/qtermscreen.cpp =================================================================== --- trunk/qterm-qt4/src/qtermscreen.cpp 2008-11-18 11:25:46 UTC (rev 523) +++ trunk/qterm-qt4/src/qtermscreen.cpp 2008-11-18 11:26:04 UTC (rev 524) @@ -21,6 +21,7 @@ #include "qtermparam.h" #include "qtermtelnet.h" #include "qtermconfig.h" +#include "qtermglobal.h" #include <QApplication> #include <QPainter> @@ -316,7 +317,7 @@ void Screen::wheelEvent( QWheelEvent * we ) { - if(m_pWindow->m_pFrame->m_pref.bWheel) + if(Global::instance()->m_pref.bWheel) QApplication::sendEvent(m_pWindow, we); else QApplication::sendEvent(m_scrollBar,we); @@ -592,19 +593,19 @@ void Screen::updateScrollBar() { - switch(m_pWindow->m_pFrame->m_nScrollPos) + switch(Global::instance()->scrollPosition()) { - case 0: + case Global::Hide: m_scrollBar->hide(); m_rcClient = QRect( 3,1, rect().width()-3, rect().height()-1 ); break; - case 1: // LEFT + case Global::Left: m_scrollBar->setGeometry( 0, 0, Scrollbar_Width, rect().height() ); m_scrollBar->show(); m_rcClient = QRect( Scrollbar_Width+3, 1, rect().width()-Scrollbar_Width-3, rect().height()-1 ); break; - case 2: // RIGHT + case Global::Right: m_scrollBar->setGeometry( rect().width()-Scrollbar_Width, 0, Scrollbar_Width, rect().height() ); m_scrollBar->show(); @@ -663,7 +664,7 @@ m_nPxmType = nType; QPalette palette; - if( m_pWindow->m_pFrame->m_bBossColor ) + if( Global::instance()->isBossColor() ) { palette.setColor(backgroundRole(), Qt::white); setPalette(palette); @@ -1088,7 +1089,7 @@ QPoint pt = mapToPixel(QPoint(x,y)); // black on white without attr - if(m_pWindow->m_pFrame->m_bBossColor) + if(Global::instance()->isBossColor()) { painter.setPen(GETFG(cp)==0?Qt::white:Qt::black); if( GETBG(cp)!=0 && !transparent ) @@ -1147,7 +1148,7 @@ if( m_pBuffer->isSelected(index) ) { rcSelect = mapToRect(m_pBuffer->getSelectRect(index, m_pWindow->m_bCopyRect)); - if(m_pWindow->m_pFrame->m_bBossColor) + if(Global::instance()->isBossColor()) painter.fillRect(rcSelect, Qt::black); else painter.fillRect(rcSelect, QBrush(m_color[7])); Modified: trunk/qterm-qt4/src/qtermwindow.cpp =================================================================== --- trunk/qterm-qt4/src/qtermwindow.cpp 2008-11-18 11:25:46 UTC (rev 523) +++ trunk/qterm-qt4/src/qtermwindow.cpp 2008-11-18 11:26:04 UTC (rev 524) @@ -293,7 +293,7 @@ m_pMessage->display(tr("Not Connected")); statusBar()->setSizeGripEnabled(false); - if(m_pFrame->m_bStatusBar) + if(Global::instance()->showStatusBar()) statusBar()->show(); else statusBar()->hide(); @@ -352,7 +352,7 @@ m_bCopyRect = false; m_bAntiIdle = true; m_bAutoReply= m_param.m_bAutoReply; - m_bBeep = !(m_pFrame->m_pref.strPlayer.isEmpty()||m_pFrame->m_pref.strWave.isEmpty()); + m_bBeep = !(Global::instance()->m_pref.strPlayer.isEmpty()||Global::instance()->m_pref.strWave.isEmpty()); m_bMouse = true; m_bWordWrap = false; m_bAutoCopy = true; @@ -486,7 +486,7 @@ //close event received void Window::closeEvent ( QCloseEvent * clse) { - if( m_bConnected && m_pFrame->m_pref.bWarn ) + if( m_bConnected && Global::instance()->m_pref.bWarn ) { QMessageBox mb( "QTerm", "Connected,Do you still want to exit?", @@ -676,7 +676,7 @@ QRect rcOld_i_dont_need_you; QRect rcUrl_leave_me_alone = m_rcUrl; bool bUrl=false; - if(m_pFrame->m_pref.bUrl) + if(Global::instance()->m_pref.bUrl) { if (m_pBBS->isIP(rcUrl_leave_me_alone, rcOld_i_dont_need_you) && m_bCheckIP) { @@ -774,7 +774,7 @@ #endif if (ok) { - QString strCmd=m_pFrame->m_pref.strHttp; + QString strCmd=Global::instance()->m_pref.strHttp; if(strCmd.indexOf("%L")==-1) // no replace //QApplication::clipboard()->setText(strUrl); strCmd += " \"" + strUrl +"\""; @@ -848,7 +848,7 @@ int j = we->delta()>0 ? 4 : 5; if(!(we->modifiers())) { - if(m_pFrame->m_pref.bWheel && m_bConnected) + if(Global::instance()->m_pref.bWheel && m_bConnected) m_pTelnet->write(direction[j], sizeof(direction[j])); return; } @@ -1046,14 +1046,14 @@ if( m_pDecode->bellReceive() ) //&& m_pBuffer->caret().y()==1 ) { if( m_bBeep ) { - m_pSound = new ExternalSound(m_pFrame->m_pref.strPlayer, - m_pFrame->m_pref.strWave); + m_pSound = new ExternalSound(Global::instance()->m_pref.strPlayer, + Global::instance()->m_pref.strWave); if (m_pSound) m_pSound->play(); delete m_pSound; m_pSound = NULL; } - if(m_pFrame->m_pref.bBlinkTab) + if(Global::instance()->m_pref.bBlinkTab) m_tabTimer->start(500); QString strMsg = m_pBBS->getMessage(); @@ -1334,7 +1334,7 @@ QClipboard *clipboard = QApplication::clipboard(); QByteArray cstrText; - if(m_pFrame->m_nClipCodec==0) + if(Global::instance()->clipCodec()==Global::GBK) { #if (QT_VERSION>=0x030100) if(clip) @@ -1369,9 +1369,9 @@ } } - if(!m_pFrame->m_strEscape.isEmpty()) + if(!Global::instance()->escapeString().isEmpty()) #if (QT_VERSION>=0x030100) - cstrText.replace(parseString(m_pFrame->m_strEscape.toLatin1()), + cstrText.replace(parseString(Global::instance()->escapeString().toLatin1()), parseString((const char *)m_param.m_strEscape.toLatin1())); #else cstrText.replace(QRegExp(parseString(m_pFrame->m_cstrEscape)), @@ -1394,8 +1394,8 @@ uint k=0, l=0; while(strText.at(j)!=QChar('\n') && j<strText.length()) { - if(m_pFrame->m_pref.nWordWrap-(l-k)>=0 && - m_pFrame->m_pref.nWordWrap-(l-k)<2) + if(Global::instance()->m_pref.nWordWrap-(l-k)>=0 && + Global::instance()->m_pref.nWordWrap-(l-k)<2) { strText.insert(j,QChar('\n')); k=l; @@ -1796,7 +1796,7 @@ { QByteArray strTmp; - if( m_pFrame->m_pref.nXIM == 0 ) + if( Global::instance()->m_pref.nXIM == 0 ) { strTmp = U2G(text); if( m_param.m_nBBSCode == 1) @@ -2191,7 +2191,7 @@ void Window::openLink() { - QString strCmd=m_pFrame->m_pref.strHttp; + QString strCmd=Global::instance()->m_pref.strHttp; if(strCmd.indexOf("%L")==-1) // no replace //QApplication::clipboard()->setText(strUrl); strCmd += " \"" + m_pBBS->getUrl() +"\""; Modified: trunk/qterm-qt4/src/qtermzmodem.cpp =================================================================== --- trunk/qterm-qt4/src/qtermzmodem.cpp 2008-11-18 11:25:46 UTC (rev 523) +++ trunk/qterm-qt4/src/qtermzmodem.cpp 2008-11-18 11:26:04 UTC (rev 524) @@ -1043,7 +1043,7 @@ //to be complete FILE *rval; int apnd=0; - QString str = Frame::instance()->m_pref.strZmPath+G2U(name); // lazy, should use bbs2unicode + QString str = Global::instance()->m_pref.strZmPath+G2U(name); // lazy, should use bbs2unicode rval = fopen(str.toLocal8Bit(), apnd ? "ab" : "wb") ; if( rval == NULL ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-18 11:26:17
|
Revision: 525 http://qterm.svn.sourceforge.net/qterm/?rev=525&view=rev Author: hephooey Date: 2008-11-18 11:26:12 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Move the load/save config to the global class Modified Paths: -------------- trunk/qterm-qt4/src/qtermconfig.cpp trunk/qterm-qt4/src/qtermconfig.h trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermglobal.h Modified: trunk/qterm-qt4/src/qtermconfig.cpp =================================================================== --- trunk/qterm-qt4/src/qtermconfig.cpp 2008-11-18 11:26:04 UTC (rev 524) +++ trunk/qterm-qt4/src/qtermconfig.cpp 2008-11-18 11:26:12 UTC (rev 525) @@ -104,6 +104,14 @@ return checkError(); } +bool Config::setItemValueNew(const QString & szSection, + const QString & szItemName, const QVariant & szItemValue) +{ + QString key = szSection+"/"+szItemName; + m_settings->setValue(key, szItemValue); + return checkError(); +} + QString Config::getItemValue(const QString & szSection, const QString & szItemName) { QString key = szSection+"/"+szItemName; @@ -115,6 +123,13 @@ } } +QVariant Config::getItemValueNew(const QString & szSection, const QString & szItemName) +{ + QString key = szSection+"/"+szItemName; + QVariant data = m_settings->value(key); + return data; +} + bool Config::renameSection(const QString & szSection, const QString & szNewName) { if (hasSection(szNewName) || !hasSection(szSection)) Modified: trunk/qterm-qt4/src/qtermconfig.h =================================================================== --- trunk/qterm-qt4/src/qtermconfig.h 2008-11-18 11:26:04 UTC (rev 524) +++ trunk/qterm-qt4/src/qtermconfig.h 2008-11-18 11:26:12 UTC (rev 525) @@ -4,6 +4,7 @@ #include <QtCore/QString> class QSettings; +class QVariant; namespace QTerm { @@ -17,9 +18,10 @@ bool save(const QString & szFileName = ""); bool setItemValue(const QString & szSection, const QString & szItemName,const QString & szItemValue); + bool setItemValueNew(const QString & szSection, const QString & szItemName,const QVariant & szItemValue); QString getItemValue(const QString & szSection, const QString & szItemName); + QVariant getItemValueNew(const QString & szSection, const QString & szItemName); - bool deleteItem(const QString & szSection, const QString & szItemName); bool deleteSection(const QString & szSection); Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:26:04 UTC (rev 524) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:26:12 UTC (rev 525) @@ -132,9 +132,10 @@ } //initialize setting from qterm.cfg -// TODO: separate config reading and UI setting + void Frame::iniSetting() { + Global::instance()->loadConfig(); Config * conf = Global::instance()->fileCfg(); QString strTmp; @@ -142,13 +143,10 @@ //TODO: // settings.setValue("size", size()); // settings.setValue("pos", pos()); - strTmp = conf->getItemValue("global", "fullscreen"); - if (strTmp == "1") { - Global::instance()->setFullScreen(true); + if (Global::instance()->isFullScreen()) { m_fullAction->setChecked(true); showFullScreen(); } else { - Global::instance()->setFullScreen(false); //window size strTmp = conf->getItemValue("global", "max"); if (strTmp == "1") @@ -164,80 +162,55 @@ } } - theme = conf->getItemValue("global", "theme"); - QStyle * style = QStyleFactory::create(theme); + QStyle * style = QStyleFactory::create(Global::instance()->style()); if (style) qApp->setStyle(style); //language - strTmp = conf->getItemValue("global", "language"); - if (strTmp == "actionEng") + if (Global::instance()->language() == Global::English) m_engAction->setChecked(true); - else if (strTmp == "actionChs") + else if (Global::instance()->language() == Global::SimpilifiedChinese) m_chsAction->setChecked(true); - else if (strTmp == "actionCht") + else if (Global::instance()->language() == Global::TraditionalChinese) m_chtAction->setChecked(true); else m_engAction->setChecked(true); m_noescAction->setChecked(true); - Global::instance()->setEscapeString(""); - //m_strEscape = ""; - strTmp = conf->getItemValue("global", "clipcodec"); - if (strTmp == "0") { - Global::instance()->setClipCodec(Global::GBK); + if (Global::instance()->clipCodec() == Global::GBK) { m_GBKAction->setChecked(true); } else { - Global::instance()->setClipCodec(Global::Big5); m_BIG5Action->setChecked(true); } - strTmp = conf->getItemValue("global", "vscrollpos"); - if (strTmp == "0") { - Global::instance()->setScrollPosition(Global::Hide); + if (Global::instance()->scrollPosition() == Global::Hide) { m_scrollHideAction->setChecked(true); - } else if (strTmp == "1") { - Global::instance()->setScrollPosition(Global::Left); + } else if (Global::instance()->scrollPosition() == Global::Left) { m_scrollLeftAction->setChecked(true); } else { - Global::instance()->setScrollPosition(Global::Right); m_scrollRightAction->setChecked(true); } - strTmp = conf->getItemValue("global", "statusbar"); - //m_bStatusBar = (strTmp != "0"); - Global::instance()->setStatusBar(strTmp != "0"); m_statusAction->setChecked(Global::instance()->showStatusBar()); - - strTmp = conf->getItemValue("global", "switchbar"); - Global::instance()->setSwitchBar((strTmp != "0")); m_switchAction->setChecked(Global::instance()->showSwitchBar()); + if (Global::instance()->showSwitchBar()) statusBar()->show(); else statusBar()->hide(); - Global::instance()->setBossColor(false); - - Global::instance()->loadPrefence(); - setUseTray(Global::instance()->m_pref.bTray); } //save current setting to qterm.cfg void Frame::saveSetting() { + Global::instance()->saveConfig(); Config * conf = Global::instance()->fileCfg(); QString strTmp; - //save font - conf->setItemValue("global", "font", qApp->font().family()); - strTmp.setNum(QFontInfo(qApp->font()).pointSize()); - conf->setItemValue("global", "pointsize", strTmp); - strTmp.setNum(QFontInfo(qApp->font()).pixelSize()); - conf->setItemValue("global", "pixelsize", strTmp); //TODO: // settings.setValue("size", size()); @@ -252,11 +225,7 @@ conf->setItemValue("global", "max", "0"); } - if (Global::instance()->isFullScreen()) - conf->setItemValue("global", "fullscreen", "1"); - else - conf->setItemValue("global", "fullscreen", "0"); - + /* // cstrTmp.setNum(theme); conf->setItemValue("global", "theme", theme); @@ -277,17 +246,8 @@ conf->setItemValue("global", "mainbar", valueToString(mdiTools->isVisibleTo(this), (int)dock, index, nl == 1 ? true : false, extra)); - +*/ // Should we convert the numbers to strings like "GBK" and "Big5"; - strTmp.setNum(Global::instance()->clipCodec()); - conf->setItemValue("global", "clipcodec", strTmp); - - strTmp.setNum(Global::instance()->scrollPosition()); - conf->setItemValue("global", "vscrollpos", strTmp); - - conf->setItemValue("global", "statusbar", Global::instance()->showStatusBar() ? "1" : "0"); - conf->setItemValue("global", "switchbar", Global::instance()->showSwitchBar() ? "1" : "0"); - conf->save(); } Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-18 11:26:04 UTC (rev 524) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-18 11:26:12 UTC (rev 525) @@ -37,8 +37,7 @@ Global * Global::instance() { static QMutex mutex; - if (!m_Instance) - { + if (!m_Instance) { mutex.lock(); if (!m_Instance) @@ -51,7 +50,7 @@ } Global::Global() - : m_fileCfg("./qterm.cfg"),m_addrCfg("./address.cfg"),m_pathLib("./"),m_pathPic("./"),m_pathCfg("./"), m_status(INIT_OK) + : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_language(Global::English) { if (!iniWorkingDir(qApp->arguments()[0])) { m_status = INIT_ERROR; @@ -101,12 +100,10 @@ void Global::clearDir(const QString & path) { QDir dir(path); - if( dir.exists() ) - { + if (dir.exists()) { const QFileInfoList list = dir.entryInfoList(); - foreach (QFileInfo fi, list) - { - if(fi.isFile()) + foreach(QFileInfo fi, list) { + if (fi.isFile()) dir.remove(fi.fileName()); } } @@ -120,8 +117,7 @@ QString strSection; - for(int i=0; i<strTmp.toInt(); i++) - { + for (int i = 0; i < strTmp.toInt(); i++) { strSection.sprintf("bbs %d", i); listName.append(m_address->getItemValue(strSection, "name")); } @@ -132,14 +128,14 @@ bool Global::loadAddress(int n, Param& param) { QString strTmp, strSection; - if(n<0) - strSection="default"; + if (n < 0) + strSection = "default"; else strSection.sprintf("bbs %d", n); // check if larger than existence - strTmp = m_address->getItemValue("bbs list","num"); - if(n>=strTmp.toInt()) + strTmp = m_address->getItemValue("bbs list", "num"); + if (n >= strTmp.toInt()) return false; param.m_strName = m_address->getItemValue(strSection, "name"); param.m_strAddr = m_address->getItemValue(strSection, "addr"); @@ -147,9 +143,9 @@ param.m_uPort = strTmp.toUShort(); strTmp = m_address->getItemValue(strSection, "hosttype"); param.m_nHostType = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "autologin"); - param.m_bAutoLogin = (strTmp!="0"); - param.m_strPreLogin = m_address->getItemValue(strSection,"prelogin"); + strTmp = m_address->getItemValue(strSection, "autologin"); + param.m_bAutoLogin = (strTmp != "0"); + param.m_strPreLogin = m_address->getItemValue(strSection, "prelogin"); param.m_strUser = m_address->getItemValue(strSection, "user"); param.m_strPasswd = m_address->getItemValue(strSection, "password"); param.m_strPostLogin = m_address->getItemValue(strSection, "postlogin"); @@ -159,11 +155,11 @@ strTmp = m_address->getItemValue(strSection, "displaycode"); param.m_nDispCode = strTmp.toInt(); strTmp = m_address->getItemValue(strSection, "autofont"); - param.m_bAutoFont = (strTmp!="0"); + param.m_bAutoFont = (strTmp != "0"); strTmp = m_address->getItemValue(strSection, "alwayshighlight"); - param.m_bAlwaysHighlight = (strTmp!="0"); + param.m_bAlwaysHighlight = (strTmp != "0"); strTmp = m_address->getItemValue(strSection, "ansicolor"); - param.m_bAnsiColor = (strTmp!="0"); + param.m_bAnsiColor = (strTmp != "0"); param.m_strFontName = m_address->getItemValue(strSection, "fontname"); strTmp = m_address->getItemValue(strSection, "fontsize"); param.m_nFontSize = strTmp.toInt(); @@ -176,7 +172,7 @@ param.m_nKey = strTmp.toInt(); strTmp = m_address->getItemValue(strSection, "column"); param.m_nCol = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "row" ); + strTmp = m_address->getItemValue(strSection, "row"); param.m_nRow = strTmp.toInt(); strTmp = m_address->getItemValue(strSection, "scroll"); param.m_nScrollLines = strTmp.toInt(); @@ -187,35 +183,35 @@ strTmp = m_address->getItemValue(strSection, "proxytype"); param.m_nProxyType = strTmp.toInt(); strTmp = m_address->getItemValue(strSection, "proxyauth"); - param.m_bAuth = (strTmp!="0"); + param.m_bAuth = (strTmp != "0"); param.m_strProxyHost = m_address->getItemValue(strSection, "proxyaddr"); strTmp = m_address->getItemValue(strSection, "proxyport"); param.m_uProxyPort = strTmp.toInt(); param.m_strProxyUser = m_address->getItemValue(strSection, "proxyuser"); param.m_strProxyPasswd = m_address->getItemValue(strSection, "proxypassword"); - strTmp = m_address->getItemValue(strSection,"protocol"); + strTmp = m_address->getItemValue(strSection, "protocol"); param.m_nProtocolType = strTmp.toInt(); strTmp = m_address->getItemValue(strSection, "maxidle"); param.m_nMaxIdle = strTmp.toInt(); param.m_strReplyKey = m_address->getItemValue(strSection, "replykey"); - if(param.m_strReplyKey.isNull()) + if (param.m_strReplyKey.isNull()) qDebug("loading null\n"); param.m_strAntiString = m_address->getItemValue(strSection, "antiidlestring"); param.m_strAutoReply = m_address->getItemValue(strSection, "autoreply"); strTmp = m_address->getItemValue(strSection, "bautoreply"); - param.m_bAutoReply = (strTmp!="0"); + param.m_bAutoReply = (strTmp != "0"); strTmp = m_address->getItemValue(strSection, "reconnect"); - param.m_bReconnect = (strTmp!="0"); + param.m_bReconnect = (strTmp != "0"); strTmp = m_address->getItemValue(strSection, "interval"); param.m_nReconnectInterval = strTmp.toInt(); strTmp = m_address->getItemValue(strSection, "retrytimes"); param.m_nRetry = strTmp.toInt(); strTmp = m_address->getItemValue(strSection, "loadscript"); - param.m_bLoadScript = (strTmp!="0"); + param.m_bLoadScript = (strTmp != "0"); param.m_strScriptFile = m_address->getItemValue(strSection, "scriptfile"); strTmp = m_address->getItemValue(strSection, "menutype"); @@ -228,8 +224,8 @@ void Global::saveAddress(int n, const Param& param) { QString strTmp, strSection; - if(n<0) - strSection="default"; + if (n < 0) + strSection = "default"; else strSection.sprintf("bbs %d", n); @@ -237,21 +233,21 @@ m_address->setItemValue(strSection, "addr", param.m_strAddr); strTmp.setNum(param.m_uPort); m_address->setItemValue(strSection, "port", strTmp); - strTmp.setNum( param.m_nHostType ); + strTmp.setNum(param.m_nHostType); m_address->setItemValue(strSection, "hosttype", strTmp); - m_address->setItemValue(strSection, "autologin", param.m_bAutoLogin?"1":"0"); - m_address->setItemValue(strSection,"prelogin", param.m_strPreLogin); - m_address->setItemValue(strSection, "user",param.m_strUser); + m_address->setItemValue(strSection, "autologin", param.m_bAutoLogin ? "1" : "0"); + m_address->setItemValue(strSection, "prelogin", param.m_strPreLogin); + m_address->setItemValue(strSection, "user", param.m_strUser); m_address->setItemValue(strSection, "password", param.m_strPasswd); - m_address->setItemValue(strSection, "postlogin",param.m_strPostLogin); + m_address->setItemValue(strSection, "postlogin", param.m_strPostLogin); - strTmp.setNum( param.m_nBBSCode ); + strTmp.setNum(param.m_nBBSCode); m_address->setItemValue(strSection, "bbscode", strTmp); strTmp.setNum(param.m_nDispCode); m_address->setItemValue(strSection, "displaycode", strTmp); - m_address->setItemValue(strSection, "autofont", param.m_bAutoFont?"1":"0"); - m_address->setItemValue(strSection, "alwayshighlight", param.m_bAlwaysHighlight?"1":"0"); - m_address->setItemValue(strSection, "ansicolor", param.m_bAnsiColor?"1":"0"); + m_address->setItemValue(strSection, "autofont", param.m_bAutoFont ? "1" : "0"); + m_address->setItemValue(strSection, "alwayshighlight", param.m_bAlwaysHighlight ? "1" : "0"); + m_address->setItemValue(strSection, "ansicolor", param.m_bAnsiColor ? "1" : "0"); m_address->setItemValue(strSection, "fontname", param.m_strFontName); strTmp.setNum(param.m_nFontSize); m_address->setItemValue(strSection, "fontsize", strTmp); @@ -259,104 +255,103 @@ m_address->setItemValue(strSection, "bgcolor", param.m_clrBg.name()); m_address->setItemValue(strSection, "schemafile", param.m_strSchemaFile); - m_address->setItemValue(strSection, "termtype",param.m_strTerm); + m_address->setItemValue(strSection, "termtype", param.m_strTerm); strTmp.setNum(param.m_nKey); - m_address->setItemValue(strSection, "keytype",strTmp); + m_address->setItemValue(strSection, "keytype", strTmp); strTmp.setNum(param.m_nCol); - m_address->setItemValue(strSection, "column",strTmp); + m_address->setItemValue(strSection, "column", strTmp); strTmp.setNum(param.m_nRow); - m_address->setItemValue(strSection, "row",strTmp); + m_address->setItemValue(strSection, "row", strTmp); strTmp.setNum(param.m_nScrollLines); - m_address->setItemValue(strSection, "scroll",strTmp); + m_address->setItemValue(strSection, "scroll", strTmp); strTmp.setNum(param.m_nCursorType); - m_address->setItemValue(strSection, "cursor",strTmp); - m_address->setItemValue(strSection, "escape",param.m_strEscape); + m_address->setItemValue(strSection, "cursor", strTmp); + m_address->setItemValue(strSection, "escape", param.m_strEscape); strTmp.setNum(param.m_nProxyType); - m_address->setItemValue(strSection, "proxytype",strTmp); - m_address->setItemValue(strSection, "proxyauth", param.m_bAuth?"1":"0"); + m_address->setItemValue(strSection, "proxytype", strTmp); + m_address->setItemValue(strSection, "proxyauth", param.m_bAuth ? "1" : "0"); m_address->setItemValue(strSection, "proxyaddr", param.m_strProxyHost); strTmp.setNum(param.m_uProxyPort); - m_address->setItemValue(strSection, "proxyport",strTmp); - m_address->setItemValue(strSection, "proxyuser",param.m_strProxyUser); - m_address->setItemValue(strSection, "proxypassword",param.m_strProxyPasswd); + m_address->setItemValue(strSection, "proxyport", strTmp); + m_address->setItemValue(strSection, "proxyuser", param.m_strProxyUser); + m_address->setItemValue(strSection, "proxypassword", param.m_strProxyPasswd); strTmp.setNum(param.m_nProtocolType); - m_address->setItemValue(strSection,"protocol",strTmp); + m_address->setItemValue(strSection, "protocol", strTmp); strTmp.setNum(param.m_nMaxIdle); m_address->setItemValue(strSection, "maxidle", strTmp); m_address->setItemValue(strSection, "replykey", param.m_strReplyKey); m_address->setItemValue(strSection, "antiidlestring", param.m_strAntiString); - m_address->setItemValue(strSection, "bautoreply", param.m_bAutoReply?"1":"0"); + m_address->setItemValue(strSection, "bautoreply", param.m_bAutoReply ? "1" : "0"); m_address->setItemValue(strSection, "autoreply", param.m_strAutoReply); - m_address->setItemValue(strSection, "reconnect", param.m_bReconnect?"1":"0"); + m_address->setItemValue(strSection, "reconnect", param.m_bReconnect ? "1" : "0"); strTmp.setNum(param.m_nReconnectInterval); m_address->setItemValue(strSection, "interval", strTmp); strTmp.setNum(param.m_nRetry); m_address->setItemValue(strSection, "retrytimes", strTmp); - m_address->setItemValue(strSection, "loadscript", param.m_bLoadScript?"1":"0"); + m_address->setItemValue(strSection, "loadscript", param.m_bLoadScript ? "1" : "0"); m_address->setItemValue(strSection, "scriptfile", param.m_strScriptFile); strTmp.setNum(param.m_nMenuType); m_address->setItemValue(strSection, "menutype", strTmp); - m_address->setItemValue(strSection, "menucolor",param.m_clrMenu.name()); + m_address->setItemValue(strSection, "menucolor", param.m_clrMenu.name()); m_address->save(); } -void Global::loadPrefence() { - Config * conf = Global::instance()->fileCfg(); +void Global::loadPrefence() +{ QString strTmp; - strTmp = conf->getItemValue("preference", "xim"); - m_pref.nXIM = strTmp.toInt()==0 ? GBK : Big5; - strTmp = conf->getItemValue("preference", "wordwrap"); + strTmp = m_config->getItemValue("preference", "xim"); + m_pref.nXIM = strTmp.toInt() == 0 ? GBK : Big5; + strTmp = m_config->getItemValue("preference", "wordwrap"); m_pref.nWordWrap = strTmp.toInt(); - strTmp = conf->getItemValue("preference", "wheel"); + strTmp = m_config->getItemValue("preference", "wheel"); m_pref.bWheel = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "url"); + strTmp = m_config->getItemValue("preference", "url"); m_pref.bUrl = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "blinktab"); + strTmp = m_config->getItemValue("preference", "blinktab"); m_pref.bBlinkTab = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "warn"); + strTmp = m_config->getItemValue("preference", "warn"); m_pref.bWarn = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "beep"); + strTmp = m_config->getItemValue("preference", "beep"); m_pref.nBeep = strTmp.toInt(); - m_pref.strWave = conf->getItemValue("preference", "wavefile"); - strTmp = conf->getItemValue("preference", "http"); + m_pref.strWave = m_config->getItemValue("preference", "wavefile"); + strTmp = m_config->getItemValue("preference", "http"); m_pref.strHttp = strTmp; - strTmp = conf->getItemValue("preference", "antialias"); + strTmp = m_config->getItemValue("preference", "antialias"); m_pref.bAA = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "tray"); + strTmp = m_config->getItemValue("preference", "tray"); m_pref.bTray = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "externalplayer"); + strTmp = m_config->getItemValue("preference", "externalplayer"); m_pref.strPlayer = strTmp; - strTmp = conf->getItemValue("preference", "clearpool"); + strTmp = m_config->getItemValue("preference", "clearpool"); m_pref.bClearPool = (strTmp != "0"); - strTmp = conf->getItemValue("preference", "pool"); + strTmp = m_config->getItemValue("preference", "pool"); m_pref.strPoolPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "pool/" : strTmp; if (m_pref.strPoolPath.right(1) != "/") m_pref.strPoolPath.append('/'); - strTmp = conf->getItemValue("preference", "zmodem"); + strTmp = m_config->getItemValue("preference", "zmodem"); m_pref.strZmPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "zmodem/" : strTmp; if (m_pref.strZmPath.right(1) != "/") m_pref.strZmPath.append('/'); - strTmp = conf->getItemValue("preference", "image"); + strTmp = m_config->getItemValue("preference", "image"); m_pref.strImageViewer = strTmp; } QString Global::getOpenFileName(const QString & filter, QWidget * widget) { - QString path = m_config->getItemValue("global","openfiledialog"); + QString path = m_config->getItemValue("global", "openfiledialog"); QString strOpen = QFileDialog::getOpenFileName(widget, "choose a file", path, filter); - if(!strOpen.isEmpty()) - { + if (!strOpen.isEmpty()) { // save the path QFileInfo fi(strOpen); - m_config->setItemValue("global","openfiledialog",fi.absolutePath()); + m_config->setItemValue("global", "openfiledialog", fi.absolutePath()); m_config->save(); } @@ -367,27 +362,25 @@ QString Global::getSaveFileName(const QString& filename, QWidget* widget) { // get the previous dir - QString path = m_config->getItemValue("global","savefiledialog"); + QString path = m_config->getItemValue("global", "savefiledialog"); - QString strSave = QFileDialog::getSaveFileName(widget, "Choose a file to save under", path+"/"+filename, "*"); + QString strSave = QFileDialog::getSaveFileName(widget, "Choose a file to save under", path + "/" + filename, "*"); QFileInfo fi(strSave); - while(fi.exists()) - { - int yn = QMessageBox::warning(widget, "QTerm", - "File exists. Overwrite?", "Yes", "No"); - if(yn==0) + while (fi.exists()) { + int yn = QMessageBox::warning(widget, "QTerm", + "File exists. Overwrite?", "Yes", "No"); + if (yn == 0) break; - strSave = QFileDialog::getSaveFileName(widget, "Choose a file to save under", path+"/"+filename, "*"); - if(strSave.isEmpty()) + strSave = QFileDialog::getSaveFileName(widget, "Choose a file to save under", path + "/" + filename, "*"); + if (strSave.isEmpty()) break; } - if(!strSave.isEmpty()) - { + if (!strSave.isEmpty()) { // save the path - m_config->setItemValue("global","savefiledialog",fi.absolutePath()); + m_config->setItemValue("global", "savefiledialog", fi.absolutePath()); m_config->save(); } @@ -395,21 +388,18 @@ } #if defined(_OS_WIN32_) || defined(Q_OS_WIN32) -bool Global::iniWorkingDir( QString param ) +bool Global::iniWorkingDir(QString param) { char ExeNamePath[MAX_PATH], _fileCfg[MAX_PATH], _addrCfg[MAX_PATH]; size_t LastSlash = 0; - if(0 == GetModuleFileNameA(NULL, ExeNamePath, MAX_PATH)) - { + if (0 == GetModuleFileNameA(NULL, ExeNamePath, MAX_PATH)) { const char *DefaultModuleName = "./qterm.exe"; strcpy(ExeNamePath, DefaultModuleName); } - for(size_t i = 0, ModuleNameLen = strlen(ExeNamePath) ; - i < ModuleNameLen ; ++i) - { - if(ExeNamePath[i] == '\\') - { + for (size_t i = 0, ModuleNameLen = strlen(ExeNamePath) ; + i < ModuleNameLen ; ++i) { + if (ExeNamePath[i] == '\\') { ExeNamePath[i] = '/'; LastSlash = i; } @@ -425,72 +415,71 @@ strcat(_addrCfg, "address.cfg"); m_addrCfg = QString::fromLocal8Bit(_addrCfg); - QString pathSchema=m_pathCfg+"schema"; - if(!isPathExist(pathSchema)) + QString pathSchema = m_pathCfg + "schema"; + if (!isPathExist(pathSchema)) return false; return true; } #else -bool Global::iniWorkingDir( QString param ) +bool Global::iniWorkingDir(QString param) { QDir dir; QFileInfo fi; #ifdef Q_OS_MACX // $HOME/Library/QTerm/ - QString pathHome=QDir::homePath(); - m_pathCfg = pathHome+"/Library/QTerm/"; - if(!isPathExist(m_pathCfg)) + QString pathHome = QDir::homePath(); + m_pathCfg = pathHome + "/Library/QTerm/"; + if (!isPathExist(m_pathCfg)) return false; - // get executive file path + // get executive file path fi.setFile(param); - m_pathLib=fi.path()+'/'; + m_pathLib = fi.path() + '/'; #else - m_pathCfg=QDir::homePath()+"/.qterm/"; - if(!isPathExist(m_pathCfg)) + m_pathCfg = QDir::homePath() + "/.qterm/"; + if (!isPathExist(m_pathCfg)) return false; // pathLib --- where datedir "pic", "cursor", "po" - if(param.indexOf('/')==-1) - m_pathLib=QTERM_DATADIR"/"; - else - { + if (param.indexOf('/') == -1) + m_pathLib = QTERM_DATADIR"/"; + else { QFileInfo fi(param); - if( fi.isSymLink() ) + if (fi.isSymLink()) param = fi.readLink(); // get the pathname - param.truncate( param.lastIndexOf('/') ); - QString oldPath=QDir::currentPath(); - QDir::setCurrent( param ); + param.truncate(param.lastIndexOf('/')); + QString oldPath = QDir::currentPath(); + QDir::setCurrent(param); dir.setPath(QTERM_BINDIR); - if( dir == QDir::current() ) - m_pathLib=QTERM_DATADIR; + if (dir == QDir::current()) + m_pathLib = QTERM_DATADIR; else - m_pathLib=QDir::currentPath(); - QDir::setCurrent( oldPath ); - m_pathLib+='/'; + m_pathLib = QDir::currentPath(); + QDir::setCurrent(oldPath); + m_pathLib += '/'; } #endif - QString pathSchema=m_pathCfg+"schema"; - if(!isPathExist(pathSchema)) + QString pathSchema = m_pathCfg + "schema"; + if (!isPathExist(pathSchema)) return false; // picPath --- $HOME/.qterm/pic prefered - m_pathPic = m_pathCfg+"pic"; - dir.setPath( m_pathPic ); - if( !dir.exists() ) + m_pathPic = m_pathCfg + "pic"; + dir.setPath(m_pathPic); + if (!dir.exists()) m_pathPic = m_pathLib; else m_pathPic = m_pathCfg; // copy configuration files - m_fileCfg=m_pathCfg+"qterm.cfg"; - if(!createLocalFile(m_fileCfg,m_pathLib+"qterm.cfg")) + m_fileCfg = m_pathCfg + "qterm.cfg"; + if (!createLocalFile(m_fileCfg, m_pathLib + "qterm.cfg")) return false; - m_addrCfg=m_pathCfg+"address.cfg"; - if(!createLocalFile(m_addrCfg,m_pathLib+"address.cfg")) + m_addrCfg = m_pathCfg + "address.cfg"; + if (!createLocalFile(m_addrCfg, m_pathLib + "address.cfg")) return false; return true; @@ -500,67 +489,63 @@ bool Global::iniSettings() { //install the translator - QString lang = m_config->getItemValue("global","language"); - if(lang !="eng" && !lang.isEmpty()) - { + QString lang = m_config->getItemValue("global", "language"); + if (lang != "eng" && !lang.isEmpty()) { // look in $HOME/.qterm/po/ first - QString qm=QDir::homePath()+"/.qterm/po/qterm_"+lang+".qm"; - if(!QFile::exists(qm)) - qm=m_pathLib+"po/qterm_"+lang+".qm"; + QString qm = QDir::homePath() + "/.qterm/po/qterm_" + lang + ".qm"; + if (!QFile::exists(qm)) + qm = m_pathLib + "po/qterm_" + lang + ".qm"; static QTranslator * translator = new QTranslator(0); translator->load(qm); qApp->installTranslator(translator); } //set font - QString family = m_config->getItemValue("global","font"); - QString pointsize = m_config->getItemValue("global","pointsize"); - QString pixelsize = m_config->getItemValue("global","pixelsize"); - if( !family.isEmpty() ) - { + QString family = m_config->getItemValue("global", "font"); + QString pointsize = m_config->getItemValue("global", "pointsize"); + QString pixelsize = m_config->getItemValue("global", "pixelsize"); + if (!family.isEmpty()) { QFont font(family); if (pointsize.toInt() > 0) font.setPointSize(pointsize.toInt()); if (pixelsize.toInt() > 0) font.setPixelSize(pixelsize.toInt()); - #if (QT_VERSION>=300) +#if (QT_VERSION>=300) QString bAA = m_config->getItemValue("global", "antialias"); - if(bAA!="0") + if (bAA != "0") font.setStyleStrategy(QFont::PreferAntialias); - #endif +#endif qApp->setFont(font); } // zmodem and pool directory QString pathZmodem = m_config->getItemValue("preference", "zmodem"); - if(pathZmodem.isEmpty()) - pathZmodem = m_pathCfg+"zmodem"; - if(!isPathExist(pathZmodem)) + if (pathZmodem.isEmpty()) + pathZmodem = m_pathCfg + "zmodem"; + if (!isPathExist(pathZmodem)) return false; QString pathPool = m_config->getItemValue("preference", "pool"); - if(pathPool.isEmpty()) - pathPool = m_pathCfg+"pool/"; + if (pathPool.isEmpty()) + pathPool = m_pathCfg + "pool/"; if (pathPool.right(1) != "/") pathPool.append('/'); - QString pathCache = pathPool+"shadow-cache/"; + QString pathCache = pathPool + "shadow-cache/"; - if((!isPathExist(pathPool))||(!isPathExist(pathCache))) + if ((!isPathExist(pathPool)) || (!isPathExist(pathCache))) return false; return true; } -bool Global::isPathExist( const QString& path ) +bool Global::isPathExist(const QString& path) { QDir dir(path); - if( ! dir.exists() ) - { - if( !dir.mkdir(path) ) - { + if (! dir.exists()) { + if (!dir.mkdir(path)) { qDebug("Failed to create directory %s", (const char*)path.toLocal8Bit()); return false; } @@ -568,85 +553,206 @@ return true; } -bool Global::createLocalFile( const QString& dst, const QString& src ) +bool Global::createLocalFile(const QString& dst, const QString& src) { QDir dir; - if(dir.exists(dst)) + if (dir.exists(dst)) return true; - if( !dir.exists(src) ) - { + if (!dir.exists(src)) { qDebug("QTerm failed to find %s.\n" "Please copy the %s from the source tarball to %s yourself.", - (const char*)src.toLocal8Bit(), (const char*)src.toLocal8Bit(), - (const char*) dst.toLocal8Bit() ); + (const char*)src.toLocal8Bit(), (const char*)src.toLocal8Bit(), + (const char*) dst.toLocal8Bit()); return false; } - if (!QFile::copy(src,dst)) - { + if (!QFile::copy(src, dst)) { qDebug("QTerm failed to copy %s to %s.\n" "Please copy the %s from the source tarball to %s yourself.", - (const char*)src.toLocal8Bit(), (const char *)dst.toLocal8Bit(), - (const char*)src.toLocal8Bit(), (const char *)dst.toLocal8Bit()); + (const char*)src.toLocal8Bit(), (const char *)dst.toLocal8Bit(), + (const char*)src.toLocal8Bit(), (const char *)dst.toLocal8Bit()); return false; } return true; } -bool Global::isBossColor() const { +bool Global::isBossColor() const +{ return m_bossColor; } -const QString & Global::escapeString() const { +const QString & Global::escapeString() const +{ return m_escape; } -Global::Codec Global::clipCodec() const { +Global::Codec Global::clipCodec() const +{ return m_clipCodec; } -bool Global::showStatusBar() const { +Global::Language Global::language() const +{ + return m_language; +} + +bool Global::showStatusBar() const +{ return m_statusBar; } -Global::Position Global::scrollPosition() const { +Global::Position Global::scrollPosition() const +{ return m_scrollPos; } -bool Global::isFullScreen() const { +bool Global::isFullScreen() const +{ return m_fullScreen; } -bool Global::showSwitchBar() const { +bool Global::showSwitchBar() const +{ return m_switchBar; } -void Global::setClipCodec(Global::Codec codec) { +void Global::setClipCodec(Global::Codec codec) +{ m_clipCodec = codec; } -void Global::setEscapeString(const QString & escapeString) { +void Global::setEscapeString(const QString & escapeString) +{ m_escape = escapeString; } -void Global::setScrollPosition(Global::Position position) { +void Global::setScrollPosition(Global::Position position) +{ m_scrollPos = position; } -void Global::setStatusBar(bool isShow) { +void Global::setStatusBar(bool isShow) +{ m_statusBar = isShow; } -void Global::setBossColor(bool isBossColor) { +void Global::setBossColor(bool isBossColor) +{ m_bossColor = isBossColor; } -void Global::setFullScreen(bool isFullscreen) { +void Global::setFullScreen(bool isFullscreen) +{ m_fullScreen = isFullscreen; } -void Global::setSwitchBar(bool isShow) { +void Global::setSwitchBar(bool isShow) +{ m_switchBar = isShow; } +void Global::setLanguage(Global::Language language) +{ + m_language = language; +} + +const QString & Global::style() const +{ + return m_style; +} + +void Global::setStyle(const QString & style) +{ + m_style = style; +} + +void Global::loadConfig() +{ + QString strTmp; + + strTmp = m_config->getItemValue("global", "fullscreen"); + if (strTmp == "1") { + setFullScreen(true); + } else { + setFullScreen(false); + } + + setStyle(m_config->getItemValue("global", "theme")); + + setEscapeString(""); + + strTmp = m_config->getItemValue("global", "clipcodec"); + if (strTmp == "0") { + setClipCodec(Global::GBK); + } else { + setClipCodec(Global::Big5); + } + + strTmp = m_config->getItemValue("global", "vscrollpos"); + if (strTmp == "0") { + setScrollPosition(Global::Hide); + } else if (strTmp == "1") { + setScrollPosition(Global::Left); + } else { + setScrollPosition(Global::Right); + } + + strTmp = m_config->getItemValue("global", "statusbar"); + setStatusBar((strTmp != "0")); + + strTmp = m_config->getItemValue("global", "switchbar"); + setSwitchBar((strTmp != "0")); + + setBossColor(false); + + loadPrefence(); + +} + +void Global::saveConfig() +{ + + QString strTmp; + //save font + m_config->setItemValue("global", "font", qApp->font().family()); + strTmp.setNum(QFontInfo(qApp->font()).pointSize()); + m_config->setItemValue("global", "pointsize", strTmp); + strTmp.setNum(QFontInfo(qApp->font()).pixelSize()); + m_config->setItemValue("global", "pixelsize", strTmp); +/* +//TODO: +// settings.setValue("size", size()); +// settings.setValue("pos", pos()); + //save window position and size + if (isMaximized()) { + conf->setItemValue("global", "max", "1"); + } else { + strTmp = QString("%1 %2 %3 %4").arg(x()).arg(y()).arg(width()).arg(height()); +// cstrTmp.sprintf("%d %d %d %d",x(),y(),width(),height()); + conf->setItemValue("global", "size", strTmp); + conf->setItemValue("global", "max", "0"); + } +*/ + if (isFullScreen()) + m_config->setItemValue("global", "fullscreen", "1"); + else + m_config->setItemValue("global", "fullscreen", "0"); + + // cstrTmp.setNum(theme); + m_config->setItemValue("global", "theme", style()); + + + // Should we convert the numbers to strings like "GBK" and "Big5"; + strTmp.setNum(clipCodec()); + m_config->setItemValue("global", "clipcodec", strTmp); + + strTmp.setNum(scrollPosition()); + m_config->setItemValue("global", "vscrollpos", strTmp); + + m_config->setItemValue("global", "statusbar", showStatusBar() ? "1" : "0"); + m_config->setItemValue("global", "switchbar", showSwitchBar() ? "1" : "0"); + m_config->save(); + +} + } // namespace QTerm Modified: trunk/qterm-qt4/src/qtermglobal.h =================================================================== --- trunk/qterm-qt4/src/qtermglobal.h 2008-11-18 11:26:04 UTC (rev 524) +++ trunk/qterm-qt4/src/qtermglobal.h 2008-11-18 11:26:12 UTC (rev 525) @@ -23,6 +23,11 @@ class Global { public: + enum Language { + SimpilifiedChinese, + TraditionalChinese, + English + }; enum Codec { GBK, Big5 @@ -69,10 +74,12 @@ bool isBossColor() const; const QString & escapeString() const; Codec clipCodec() const; + Language language() const; bool showStatusBar() const; Position scrollPosition() const; bool isFullScreen() const; bool showSwitchBar() const; + const QString & style() const; void setClipCodec(Codec codecId); void setEscapeString(const QString & escapeString); @@ -81,6 +88,10 @@ void setBossColor(bool isBossColor); void setFullScreen(bool isFullscreen); void setSwitchBar(bool isShow); + void setLanguage(const Language language); + void setStyle(const QString & style); + void loadConfig(); //TODO: Merge with iniSettings + void saveConfig(); private: Global(); @@ -96,7 +107,9 @@ QString m_pathCfg; Config * m_config; Config * m_address; + QByteArray * m_windowState; Status m_status; + QString m_style; bool m_bossColor; QString m_escape; Codec m_clipCodec; @@ -104,7 +117,7 @@ Position m_scrollPos; bool m_fullScreen; bool m_switchBar; - + Language m_language; }; } // namespace QTerm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-18 11:26:23
|
Revision: 526 http://qterm.svn.sourceforge.net/qterm/?rev=526&view=rev Author: hephooey Date: 2008-11-18 11:26:20 +0000 (Tue, 18 Nov 2008) Log Message: ----------- New config loading/saving code, we also remember the state and the geometry of the window now. Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermglobal.h Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:26:12 UTC (rev 525) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:26:20 UTC (rev 526) @@ -83,8 +83,6 @@ tray = 0; trayMenu = 0; - connect(this, SIGNAL(toolBarPositionChanged(QToolBar*)), - this, SLOT(toolBarPosChanged(QToolBar*))); //create a tabbar in the hbox tabBar = new QTabBar(statusBar()); @@ -136,30 +134,12 @@ void Frame::iniSetting() { Global::instance()->loadConfig(); - Config * conf = Global::instance()->fileCfg(); - QString strTmp; - -//TODO: -// settings.setValue("size", size()); -// settings.setValue("pos", pos()); + restoreGeometry(Global::instance()->loadGeometry()); + restoreState(Global::instance()->loadState()); if (Global::instance()->isFullScreen()) { m_fullAction->setChecked(true); showFullScreen(); - } else { - //window size - strTmp = conf->getItemValue("global", "max"); - if (strTmp == "1") - showMaximized(); - else { - QString size = conf->getItemValue("global", "size"); - if (!size.isNull()) { - int x, y, cx, cy; - sscanf(size.toLatin1(), "%d %d %d %d", &x, &y, &cx, &cy); - resize(QSize(cx, cy)); - move(QPoint(x, y)); - } - } } QStyle * style = QStyleFactory::create(Global::instance()->style()); @@ -204,51 +184,11 @@ setUseTray(Global::instance()->m_pref.bTray); } -//save current setting to qterm.cfg void Frame::saveSetting() { + Global::instance()->saveGeometry(saveGeometry()); + Global::instance()->saveState(saveState()); Global::instance()->saveConfig(); - Config * conf = Global::instance()->fileCfg(); - - QString strTmp; - -//TODO: -// settings.setValue("size", size()); -// settings.setValue("pos", pos()); - //save window position and size - if (isMaximized()) { - conf->setItemValue("global", "max", "1"); - } else { - strTmp = QString("%1 %2 %3 %4").arg(x()).arg(y()).arg(width()).arg(height()); -// cstrTmp.sprintf("%d %d %d %d",x(),y(),width(),height()); - conf->setItemValue("global", "size", strTmp); - conf->setItemValue("global", "max", "0"); - } - - /* - // cstrTmp.setNum(theme); - conf->setItemValue("global", "theme", theme); - - int hide, dock, index, nl, extra; - - strTmp = conf->getItemValue("global", "bbsbar"); - sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); - conf->setItemValue("global", "bbsbar", valueToString(mdiconnectTools->isVisibleTo(this), - (int)dock, index, nl == 1 ? true : false, extra)); - - strTmp = conf->getItemValue("global", "keybar"); - sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); - conf->setItemValue("global", "keybar", valueToString(key->isVisibleTo(this), - (int)dock, index, nl == 1 ? true : false, extra)); - - strTmp = conf->getItemValue("global", "mainbar"); - sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); - conf->setItemValue("global", "mainbar", valueToString(mdiTools->isVisibleTo(this), - (int)dock, index, nl == 1 ? true : false, extra)); - -*/ - // Should we convert the numbers to strings like "GBK" and "Big5"; - conf->save(); } //addressbook @@ -593,13 +533,14 @@ } } -void Frame::fullscreen() +void Frame::triggerFullScreen(bool isFullScreen) { - bool tmp = ! Global::instance()->isFullScreen(); - Global::instance()->setFullScreen(tmp); + Global::instance()->setFullScreen(isFullScreen); - if (tmp) { - //TODO: add an item to the popup menu so we can go back to normal without touch the keyboard + //TODO: add an item to the popup menu so we can go back to normal without touch the keyboard + if (isFullScreen) { + Global::instance()->saveGeometry(saveGeometry()); + Global::instance()->saveState(saveState()); menuBar()->hide(); mdiTools->hide(); mdiconnectTools->hide(); @@ -609,16 +550,15 @@ showFullScreen(); } else { menuBar()->show(); - mdiTools->show(); - mdiconnectTools->show(); - key->show(); + restoreGeometry(Global::instance()->loadGeometry()); + restoreState(Global::instance()->loadState()); emit scrollChanged(); + showNormal(); //showStatusBar(); //showSwitchBar(); - showNormal(); } - m_fullAction->setChecked(tmp); + m_fullAction->setChecked(isFullScreen); } @@ -786,32 +726,11 @@ } } -void Frame::toolBarPosChanged(QToolBar*) -{ - Config * conf = Global::instance()->fileCfg(); - -// Qt::ToolBarDock dock; - int index; - bool nl; - int extra; - -// TODO: Position of the tool bar? - conf->save(); -} - void Frame::addMainTool() { mdiTools = addToolBar("Main ToolBar"); + mdiTools->setObjectName("mainToolBar"); - Config * conf = Global::instance()->fileCfg(); - int hide, dock, index, nl, extra; - - QString strTmp = conf->getItemValue("global", "mainbar"); - if (!strTmp.isEmpty()) { - sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); - if (hide == 0) - mdiTools->hide(); - } connectButton = new QToolButton(mdiTools); connectButton->setIcon(QPixmap(Global::instance()->pathPic() + "pic/connect.png")); @@ -825,19 +744,11 @@ mdiTools->addAction(m_quickConnectAction); // custom define key = addToolBar("Custom Key"); - strTmp = conf->getItemValue("global", "keybar"); - if (!strTmp.isEmpty()) { - sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); - if (hide == 0) - key->hide(); - } + key->setObjectName("customKeyToolBar"); // the toolbar mdiconnectTools = addToolBar("bbs operations"); - strTmp = conf->getItemValue("global", "bbbar"); - if (!strTmp.isEmpty()) { - sscanf(strTmp.toLatin1(), "%d %d %d %d %d", &hide, &dock, &index, &nl, &extra); - } + mdiconnectTools->setObjectName("bbsOperationsToolBar"); mdiconnectTools->addAction(m_disconnectAction); mdiconnectTools->addSeparator(); @@ -987,6 +898,7 @@ m_uiFontAction->setObjectName("actionUiFont"); m_fullAction = new QAction(tr("&Fullscreen"), this); m_fullAction->setObjectName("actionFull"); + m_fullAction->setCheckable(true); m_fullAction->setShortcut(Qt::Key_F6); addAction(m_fullAction); m_bossAction = new QAction(tr("Boss &Color"), this); @@ -1082,7 +994,7 @@ connect(langGroup, SIGNAL(triggered(QAction*)), this, SLOT(updateLang(QAction*))); connect(m_uiFontAction, SIGNAL(triggered()), this, SLOT(uiFont())); - connect(m_fullAction, SIGNAL(triggered()), this, SLOT(fullscreen())); + connect(m_fullAction, SIGNAL(toggled(bool)), this, SLOT(triggerFullScreen(bool))); connect(m_bossAction, SIGNAL(triggered()), this, SLOT(bosscolor())); connect(scrollGroup, SIGNAL(triggered(QAction*)), this, SLOT(updateScroll(QAction*))); Modified: trunk/qterm-qt4/src/qtermframe.h =================================================================== --- trunk/qterm-qt4/src/qtermframe.h 2008-11-18 11:26:12 UTC (rev 525) +++ trunk/qterm-qt4/src/qtermframe.h 2008-11-18 11:26:20 UTC (rev 526) @@ -49,7 +49,6 @@ protected slots: void keyClicked(int); - void toolBarPosChanged(QToolBar*); // Menu void addressBook(); void quickLogin(); @@ -82,7 +81,7 @@ void font(); void color(); void refresh(); - void fullscreen(); + void triggerFullScreen(bool isFullScreen); void bosscolor(); void uiFont(); void antiIdle(bool); Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-18 11:26:12 UTC (rev 525) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-18 11:26:20 UTC (rev 526) @@ -17,6 +17,7 @@ #include <QtCore/QDir> #include <QtCore/QFileInfo> #include <QtCore/QTranslator> +#include <QtCore/QVariant> #include <QtGui/QApplication> #include <QtGui/QFileDialog> #include <QtGui/QMessageBox> @@ -50,7 +51,7 @@ } Global::Global() - : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_language(Global::English) + : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_fullScreen(false), m_language(Global::English) { if (!iniWorkingDir(qApp->arguments()[0])) { m_status = INIT_ERROR; @@ -669,8 +670,8 @@ void Global::loadConfig() { QString strTmp; + strTmp = m_config->getItemValue("global", "fullscreen"); - strTmp = m_config->getItemValue("global", "fullscreen"); if (strTmp == "1") { setFullScreen(true); } else { @@ -719,20 +720,7 @@ m_config->setItemValue("global", "pointsize", strTmp); strTmp.setNum(QFontInfo(qApp->font()).pixelSize()); m_config->setItemValue("global", "pixelsize", strTmp); -/* -//TODO: -// settings.setValue("size", size()); -// settings.setValue("pos", pos()); - //save window position and size - if (isMaximized()) { - conf->setItemValue("global", "max", "1"); - } else { - strTmp = QString("%1 %2 %3 %4").arg(x()).arg(y()).arg(width()).arg(height()); -// cstrTmp.sprintf("%d %d %d %d",x(),y(),width(),height()); - conf->setItemValue("global", "size", strTmp); - conf->setItemValue("global", "max", "0"); - } -*/ + if (isFullScreen()) m_config->setItemValue("global", "fullscreen", "1"); else @@ -755,4 +743,23 @@ } +QByteArray Global::loadGeometry() +{ + return m_config->getItemValueNew("global","geometry").toByteArray(); +} + +QByteArray Global::loadState() +{ + return m_config->getItemValueNew("global","state").toByteArray(); +} + +void Global::saveGeometry(const QByteArray geometry) +{ + m_config->setItemValueNew("global", "geometry", geometry); +} + +void Global::saveState(const QByteArray state) +{ + m_config->setItemValueNew("global", "state", state); +} } // namespace QTerm Modified: trunk/qterm-qt4/src/qtermglobal.h =================================================================== --- trunk/qterm-qt4/src/qtermglobal.h 2008-11-18 11:26:12 UTC (rev 525) +++ trunk/qterm-qt4/src/qtermglobal.h 2008-11-18 11:26:20 UTC (rev 526) @@ -92,6 +92,10 @@ void setStyle(const QString & style); void loadConfig(); //TODO: Merge with iniSettings void saveConfig(); + QByteArray loadGeometry(); + QByteArray loadState(); + void saveGeometry( const QByteArray geometry); + void saveState( const QByteArray state); private: Global(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-18 11:26:37
|
Revision: 527 http://qterm.svn.sourceforge.net/qterm/?rev=527&view=rev Author: hephooey Date: 2008-11-18 11:26:31 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Move++ Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermglobal.h Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:26:20 UTC (rev 526) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-18 11:26:31 UTC (rev 527) @@ -405,13 +405,7 @@ } saveSetting(); - // clear zmodem and pool if needed - // FIXME: cleanup the code - if (Global::instance()->m_pref.bClearPool) { - Global::instance()->clearDir(Global::instance()->m_pref.strZmPath); - Global::instance()->clearDir(Global::instance()->m_pref.strPoolPath); - Global::instance()->clearDir(Global::instance()->m_pref.strPoolPath + "shadow-cache/"); - } + Global::instance()->cleanup(); setUseTray(false); Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-18 11:26:20 UTC (rev 526) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-18 11:26:31 UTC (rev 527) @@ -762,4 +762,14 @@ { m_config->setItemValueNew("global", "state", state); } + +void Global::cleanup() +{ + if (m_pref.bClearPool) { + clearDir(m_pref.strZmPath); + clearDir(m_pref.strPoolPath); + clearDir(m_pref.strPoolPath + "shadow-cache/"); + } +} + } // namespace QTerm Modified: trunk/qterm-qt4/src/qtermglobal.h =================================================================== --- trunk/qterm-qt4/src/qtermglobal.h 2008-11-18 11:26:20 UTC (rev 526) +++ trunk/qterm-qt4/src/qtermglobal.h 2008-11-18 11:26:31 UTC (rev 527) @@ -96,6 +96,7 @@ QByteArray loadState(); void saveGeometry( const QByteArray geometry); void saveState( const QByteArray state); + void cleanup(); private: Global(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-24 22:55:21
|
Revision: 531 http://qterm.svn.sourceforge.net/qterm/?rev=531&view=rev Author: hephooey Date: 2008-11-24 21:39:06 +0000 (Mon, 24 Nov 2008) Log Message: ----------- Use KDE notification function if possible, the introduction of DBus probably breaks Windows support. Modified Paths: -------------- trunk/qterm-qt4/src/CMakeLists.txt trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermglobal.h trunk/qterm-qt4/src/qtermwindow.cpp Modified: trunk/qterm-qt4/src/CMakeLists.txt =================================================================== --- trunk/qterm-qt4/src/CMakeLists.txt 2008-11-19 17:27:28 UTC (rev 530) +++ trunk/qterm-qt4/src/CMakeLists.txt 2008-11-24 21:39:06 UTC (rev 531) @@ -100,6 +100,7 @@ ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR} + ${QT_QTDBUS_INCLUDE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} @@ -110,6 +111,7 @@ ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} + ${QT_QTDBUS_LIBRARY} ${optionalLibs}) if(WIN32) target_link_libraries(qterm ${win32Libs}) Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-19 17:27:28 UTC (rev 530) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-24 21:39:06 UTC (rev 531) @@ -21,6 +21,7 @@ #include <QtGui/QApplication> #include <QtGui/QFileDialog> #include <QtGui/QMessageBox> +#include <QtDBus> #if defined(_OS_WIN32_) || defined(Q_OS_WIN32) #ifndef MAX_PATH @@ -34,6 +35,9 @@ { Global * Global::m_Instance = 0; +static const QString dbusServiceName = "org.kde.VisualNotifications"; +static const QString dbusInterfaceName = "org.kde.VisualNotifications"; +static const QString dbusPath = "/VisualNotifications"; Global * Global::instance() { @@ -772,4 +776,30 @@ } } +bool Global::dbusExist() const +{ + return QDBusConnection::sessionBus().interface()->isServiceRegistered(dbusServiceName); +} + +bool Global::sendDBusNotification(const QString & summary, const QString & body) +{ + QDBusMessage message = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "Notify" ); + uint id = 0; + QList<QVariant> args; + args.append("QTerm"); + args.append(id); // If I send 0 directly, this will be an int32 instead of uin32, resulting an unknown method error. + args.append(QString()); + args.append(QString()); + args.append(summary); + args.append(body); + QStringList actionList; + args.append(actionList); + args.append(QVariantMap()); + args.append(6*1000); + message.setArguments(args); + QDBusMessage response = QDBusConnection::sessionBus().call(message); + //TODO: handle errors + return true; +} + } // namespace QTerm Modified: trunk/qterm-qt4/src/qtermglobal.h =================================================================== --- trunk/qterm-qt4/src/qtermglobal.h 2008-11-19 17:27:28 UTC (rev 530) +++ trunk/qterm-qt4/src/qtermglobal.h 2008-11-24 21:39:06 UTC (rev 531) @@ -79,6 +79,7 @@ Position scrollPosition() const; bool isFullScreen() const; bool showSwitchBar() const; + bool dbusExist() const; const QString & style() const; void setClipCodec(Codec codecId); @@ -97,6 +98,7 @@ void saveGeometry( const QByteArray geometry); void saveState( const QByteArray state); void cleanup(); + bool sendDBusNotification(const QString & summary, const QString & body); private: Global(); Modified: trunk/qterm-qt4/src/qtermwindow.cpp =================================================================== --- trunk/qterm-qt4/src/qtermwindow.cpp 2008-11-19 17:27:28 UTC (rev 530) +++ trunk/qterm-qt4/src/qtermwindow.cpp 2008-11-24 21:39:06 UTC (rev 531) @@ -1064,8 +1064,12 @@ if(!isActiveWindow() || m_pFrame->wndmgr->activeWindow()!=this) { - m_popWin->setText(fromBBSCodec(strMsg.toLatin1())); - m_popWin->popup(); + if (Global::instance()->dbusExist()) { + Global::instance()->sendDBusNotification("New Message in QTerm", fromBBSCodec(strMsg.toLatin1())); + } else { + m_popWin->setText(fromBBSCodec(strMsg.toLatin1())); + m_popWin->popup(); + } } if(m_bAutoReply) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-24 22:55:35
|
Revision: 540 http://qterm.svn.sourceforge.net/qterm/?rev=540&view=rev Author: hephooey Date: 2008-11-24 21:40:16 +0000 (Mon, 24 Nov 2008) Log Message: ----------- Toolbar configuration dialog. Modified Paths: -------------- trunk/qterm-qt4/src/CMakeLists.txt trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h Added Paths: ----------- trunk/qterm-qt4/src/toolbardialog.cpp trunk/qterm-qt4/src/toolbardialog.h trunk/qterm-qt4/src/ui/toolbardialog.ui Modified: trunk/qterm-qt4/src/CMakeLists.txt =================================================================== --- trunk/qterm-qt4/src/CMakeLists.txt 2008-11-24 21:40:05 UTC (rev 539) +++ trunk/qterm-qt4/src/CMakeLists.txt 2008-11-24 21:40:16 UTC (rev 540) @@ -33,6 +33,7 @@ ui_soundconf.h ui_sshlogin.h ui_shortcutsdialog.h + ui_toolbardialog.h ui_zmodemdialog.h aboutdialog.cpp addrdialog.cpp @@ -71,6 +72,7 @@ schemadialog.cpp shortcutsdialog.cpp statusBar.cpp + toolbardialog.cpp zmodemdialog.cpp hostinfo.cpp ${optionalSources}) @@ -87,6 +89,7 @@ ui/shortcutsdialog.ui ui/soundconf.ui ui/sshlogin.ui + ui/toolbardialog.ui ui/zmodemdialog.ui) set(qterm_MISC address.cfg Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:40:05 UTC (rev 539) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:40:16 UTC (rev 540) @@ -27,6 +27,7 @@ #include "trayicon.h" #include "imageviewer.h" #include "shortcutsdialog.h" +#include "toolbardialog.h" #include <QPaintEvent> #include <QMouseEvent> @@ -957,6 +958,9 @@ m_shortcutsAction = new QAction(tr("Configure Shortcuts..."),this); m_shortcutsAction->setObjectName("actionShortcuts"); + m_toolbarsAction = new QAction(tr("Configure Toolbars..."),this); + m_toolbarsAction->setObjectName("actionToolbars"); + connect(m_connectAction, SIGNAL(triggered()), this, SLOT(connectIt())); connect(m_disconnectAction, SIGNAL(triggered()), this, SLOT(disconnect())); connect(m_addressAction, SIGNAL(triggered()), this, SLOT(addressBook())); @@ -1008,6 +1012,7 @@ connect(m_reconnectAction, SIGNAL(toggled(bool)), this, SLOT(reconnect(bool))); connect(m_shortcutsAction, SIGNAL(triggered()), this, SLOT(configShortcuts())); + connect(m_toolbarsAction, SIGNAL(triggered()), this, SLOT(configToolbars())); } void Frame::addMainMenu() @@ -1091,6 +1096,7 @@ option->addAction(m_prefAction); option->addSeparator(); option->addAction(m_shortcutsAction); + option->addAction(m_toolbarsAction); // Special QMenu * spec = new QMenu(tr("&Special"), this); @@ -1435,6 +1441,14 @@ setIconSize(conf->getItemValue("Toolbars", "IconSize").toSize()); } +void Frame::configToolbars() +{ + ToolbarDialog td(this); + td.exec(); + + saveToolbars(); } +} + #include <qtermframe.moc> Modified: trunk/qterm-qt4/src/qtermframe.h =================================================================== --- trunk/qterm-qt4/src/qtermframe.h 2008-11-24 21:40:05 UTC (rev 539) +++ trunk/qterm-qt4/src/qtermframe.h 2008-11-24 21:40:16 UTC (rev 540) @@ -111,6 +111,7 @@ void paintEvent(QPaintEvent *); void configShortcuts(); + void configToolbars(); public: QTabBar *tabBar; WndMgr * wndmgr; @@ -185,6 +186,7 @@ QAction * m_reconnectAction; QAction * m_shortcutsAction; + QAction * m_toolbarsAction; StatusBar * m_pStatusBar; Added: trunk/qterm-qt4/src/toolbardialog.cpp =================================================================== --- trunk/qterm-qt4/src/toolbardialog.cpp (rev 0) +++ trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-24 21:40:16 UTC (rev 540) @@ -0,0 +1,195 @@ +#include "toolbardialog.h" + +#include <QToolBar> +#include <QRegExp> +#include <QSettings> +#include <QMainWindow> + +ToolbarDialog::ToolbarDialog(QWidget* parent) + : QDialog(parent) +{ + setupUi(this); + + // populate all available actions + QList<QAction*> actions = parent->findChildren<QAction*>(QRegExp("action*")); + QAction* action; + foreach(action, actions) { + QListWidgetItem* item = new QListWidgetItem(action->toolTip()); + item->setIcon(action->icon()); + item->setData(Qt::UserRole, QVariant::fromValue((QObject*)action)); + listAllActions->addItem(item); + } + // Important to add special Separator + listAllActions->addItem("Separator"); + + QList<QToolBar*> toolbars = parent->findChildren<QToolBar*>(); + QToolBar* toolbar; + foreach(toolbar, toolbars) + comboToolbars->addItem(toolbar->windowTitle(), QVariant::fromValue((QObject*)toolbar)); + comboToolbarsCurrentIndexChanged(0); + + QMainWindow *mwParent = qobject_cast<QMainWindow*>(parent); + + comboButtonStyle->setCurrentIndex(int(mwParent->toolButtonStyle())); + QVariant size(mwParent->iconSize()); + for (int index = 0; index < comboIconSize->count(); index++) + if (size.toString() == comboIconSize->itemText(index)) + comboIconSize->setCurrentIndex(index); + connect(buttonUp, SIGNAL(clicked()), this, SLOT(buttonUpClicked())); + connect(buttonDown, SIGNAL(clicked()), this, SLOT(buttonDownClicked())); + connect(buttonAdd, SIGNAL(clicked()), this, SLOT(buttonAddClicked())); + connect(buttonRemove, SIGNAL(clicked()), this, SLOT(buttonRemoveClicked())); + connect(comboToolbars, SIGNAL(currentIndexChanged(int)), this, SLOT(comboToolbarsCurrentIndexChanged(int))); + connect(comboIconSize, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(comboIconSizeCurrentIndexChanged(const QString &))); + connect(comboButtonStyle, SIGNAL(currentIndexChanged(int)),this, SLOT(comboButtonStyleCurrentIndexChanged(int))); + +} + +ToolbarDialog::~ToolbarDialog() +{ +} + +void ToolbarDialog::buttonAddClicked() +{ + // get the target toolar + QVariant v; + v = comboToolbars->itemData(comboToolbars->currentIndex()); + QToolBar *toolbar = qobject_cast<QToolBar*>(v.value<QObject*>()); + + // get the action to be added + QListWidgetItem* itemSrc = listAllActions->currentItem(); + if (itemSrc == NULL) + return; + v = itemSrc->data(Qt::UserRole); + QAction *actionSrc = qobject_cast<QAction*>(v.value<QObject*>()); + + if (toolbar->actions().contains(actionSrc)) + return; + + // get the position to be inserted + QListWidgetItem* itemPos = listUsedActions->currentItem(); + QAction *actionCurrent = 0; + QListWidgetItem* itemNew = new QListWidgetItem(); + + if (itemPos != 0) { //get the currentItem data if have one + v = itemPos->data(Qt::UserRole); + actionCurrent = qobject_cast<QAction*>(v.value<QObject*>()); + } + if (itemSrc->text() == "Separator") { + actionSrc = toolbar->insertSeparator(actionCurrent); + itemNew->setText("Separator"); + } else { + toolbar->insertAction(actionCurrent, actionSrc); + itemNew->setText(actionSrc->toolTip()); + itemNew->setIcon(actionSrc->icon()); + } + itemNew->setData(Qt::UserRole, + QVariant::fromValue((QObject*)actionSrc)); + if (listUsedActions->currentRow() == -1) //append if nothing selected, consistent with QObject::insertAction(); + listUsedActions->addItem(itemNew); + else + listUsedActions->insertItem(listUsedActions->currentRow(), itemNew); + listUsedActions->setCurrentItem(itemNew); +} + +void ToolbarDialog::buttonRemoveClicked() +{ + // get the target toolar + QVariant v; + v = comboToolbars->itemData(comboToolbars->currentIndex()); + QToolBar *toolbar = qobject_cast<QToolBar*>(v.value<QObject*>()); + + // get the action to be removed + QListWidgetItem* itemPos = listUsedActions->currentItem(); + if (itemPos != 0) { //get the currentItem data if have one + v = itemPos->data(Qt::UserRole); + QAction *actionCurrent = qobject_cast<QAction*>(v.value<QObject*>()); + toolbar->removeAction(actionCurrent); + delete itemPos; + } + +} + +void ToolbarDialog::buttonUpClicked() +{ + // get the target toolar + QVariant v; + v = comboToolbars->itemData(comboToolbars->currentIndex()); + QToolBar *toolbar = qobject_cast<QToolBar*>(v.value<QObject*>()); + + int index = listUsedActions->currentRow(); + if (index <= 0) // either the first or nothing selected + return; + + // take out current action/item + QListWidgetItem* itemCurrent = listUsedActions->takeItem(index); + v = itemCurrent->data(Qt::UserRole); + QAction *actionCurrent = qobject_cast<QAction*>(v.value<QObject*>()); + toolbar->removeAction(actionCurrent); + // insert it back + QListWidgetItem* itemBefore = listUsedActions->item(index - 1); + v = itemBefore->data(Qt::UserRole); + QAction *actionBefore = qobject_cast<QAction*>(v.value<QObject*>()); + toolbar->insertAction(actionBefore, actionCurrent); + listUsedActions->insertItem(index - 1, itemCurrent); + listUsedActions->setCurrentItem(itemCurrent); +} + +void ToolbarDialog::buttonDownClicked() +{ + // get the target toolar + QVariant v; + v = comboToolbars->itemData(comboToolbars->currentIndex()); + QToolBar *toolbar = qobject_cast<QToolBar*>(v.value<QObject*>()); + + int index = listUsedActions->currentRow(); + if (index < 0 || index == listUsedActions->count() - 1) // either the last or nothing selected + return; + + // take out action/item behind + QListWidgetItem* itemBehind = listUsedActions->takeItem(index + 1); + v = itemBehind->data(Qt::UserRole); + QAction *actionBehind = qobject_cast<QAction*>(v.value<QObject*>()); + toolbar->removeAction(actionBehind); + + // insert it back + QListWidgetItem* itemCurrent = listUsedActions->item(index); + v = itemCurrent->data(Qt::UserRole); + QAction *actionCurrent = qobject_cast<QAction*>(v.value<QObject*>()); + toolbar->insertAction(actionCurrent, actionBehind); + listUsedActions->insertItem(index, itemBehind); +} + +void ToolbarDialog::comboButtonStyleCurrentIndexChanged(int index) +{ + QMainWindow *parent = qobject_cast<QMainWindow*>(parentWidget()); + parent->setToolButtonStyle(Qt::ToolButtonStyle(index)); +} + +void ToolbarDialog::comboIconSizeCurrentIndexChanged(const QString& item) +{ + QVariant v; + v.setValue(item); + QMainWindow *parent = qobject_cast<QMainWindow*>(parentWidget()); + parent->setIconSize(v.toSize()); +} + +void ToolbarDialog::comboToolbarsCurrentIndexChanged(int index) +{ + listUsedActions->clear(); + QToolBar *toolbar = qobject_cast<QToolBar*>(comboToolbars->itemData(index).value<QObject*>()); + foreach(QAction *action, toolbar->actions()) { + QListWidgetItem* item = new QListWidgetItem(); + if (action->isSeparator()) + item->setText("Separator"); + else { + item->setText(action->toolTip()); + item->setIcon(action->icon()); + } + item->setData(Qt::UserRole, + QVariant::fromValue((QObject*)action)); + listUsedActions->addItem(item); + } +} + +#include <toolbardialog.moc> Added: trunk/qterm-qt4/src/toolbardialog.h =================================================================== --- trunk/qterm-qt4/src/toolbardialog.h (rev 0) +++ trunk/qterm-qt4/src/toolbardialog.h 2008-11-24 21:40:16 UTC (rev 540) @@ -0,0 +1,25 @@ +#ifndef TOOLBARDIALOG_H +#define TOOLBARDIALOG_H + +#include "ui_toolbardialog.h" + +class ToolbarDialog : public QDialog, public Ui_ToolbarDialog +{ + Q_OBJECT +public: + ToolbarDialog(QWidget*); + ~ToolbarDialog(); + +public slots: + void buttonUpClicked(); + void buttonDownClicked(); + + void buttonAddClicked(); + void buttonRemoveClicked(); + + void comboToolbarsCurrentIndexChanged(int); + void comboIconSizeCurrentIndexChanged(const QString&); + void comboButtonStyleCurrentIndexChanged(int); +}; + +#endif //TOOLBARDIALOG_H Added: trunk/qterm-qt4/src/ui/toolbardialog.ui =================================================================== --- trunk/qterm-qt4/src/ui/toolbardialog.ui (rev 0) +++ trunk/qterm-qt4/src/ui/toolbardialog.ui 2008-11-24 21:40:16 UTC (rev 540) @@ -0,0 +1,313 @@ +<ui version="4.0" > + <class>ToolbarDialog</class> + <widget class="QDialog" name="ToolbarDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>668</width> + <height>479</height> + </rect> + </property> + <property name="windowTitle" > + <string>Configure Toolbars</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="2" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>91</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>111</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="2" colspan="2" > + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="1" > + <widget class="QPushButton" name="buttonUp" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="text" > + <string>^</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QPushButton" name="buttonDown" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="baseSize" > + <size> + <width>77</width> + <height>27</height> + </size> + </property> + <property name="text" > + <string>V</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QPushButton" name="buttonRemove" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="text" > + <string><</string> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QPushButton" name="buttonAdd" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="baseSize" > + <size> + <width>41</width> + <height>27</height> + </size> + </property> + <property name="text" > + <string>></string> + </property> + </widget> + </item> + </layout> + </item> + <item row="6" column="0" colspan="5" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>361</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="6" column="5" > + <widget class="QPushButton" name="buttonDone" > + <property name="text" > + <string>Done</string> + </property> + </widget> + </item> + <item row="4" column="3" colspan="3" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>131</width> + <height>21</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="3" colspan="3" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>131</width> + <height>21</height> + </size> + </property> + </spacer> + </item> + <item rowspan="3" row="0" column="0" colspan="2" > + <layout class="QVBoxLayout" > + <property name="spacing" > + <number>6</number> + </property> + <property name="margin" > + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Available Actions</string> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="listAllActions" /> + </item> + </layout> + </item> + <item row="3" column="1" colspan="2" > + <widget class="QComboBox" name="comboButtonStyle" > + <item> + <property name="text" > + <string>Icon Only</string> + </property> + </item> + <item> + <property name="text" > + <string>Text Only</string> + </property> + </item> + <item> + <property name="text" > + <string>Text beside Icon</string> + </property> + </item> + <item> + <property name="text" > + <string>Text below Icon</string> + </property> + </item> + </widget> + </item> + <item row="4" column="1" colspan="2" > + <widget class="QComboBox" name="comboIconSize" > + <item> + <property name="text" > + <string>16x16</string> + </property> + </item> + <item> + <property name="text" > + <string>32x32</string> + </property> + </item> + <item> + <property name="text" > + <string>48x48</string> + </property> + </item> + </widget> + </item> + <item row="5" column="0" colspan="6" > + <widget class="Line" name="line" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Show</string> + </property> + </widget> + </item> + <item row="4" column="0" > + <widget class="QLabel" name="label_3" > + <property name="text" > + <string>Icon Size</string> + </property> + </widget> + </item> + <item rowspan="3" row="0" column="4" colspan="2" > + <layout class="QVBoxLayout" > + <property name="spacing" > + <number>6</number> + </property> + <property name="margin" > + <number>0</number> + </property> + <item> + <widget class="QComboBox" name="comboToolbars" /> + </item> + <item> + <widget class="QListWidget" name="listUsedActions" /> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonDone</sender> + <signal>clicked()</signal> + <receiver>ToolbarDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>278</x> + <y>253</y> + </hint> + <hint type="destinationlabel" > + <x>96</x> + <y>254</y> + </hint> + </hints> + </connection> + </connections> +</ui> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-24 22:55:43
|
Revision: 535 http://qterm.svn.sourceforge.net/qterm/?rev=535&view=rev Author: hephooey Date: 2008-11-24 21:39:42 +0000 (Mon, 24 Nov 2008) Log Message: ----------- 1. New shortcuts configuration dialog 2. 'Shortcut'->'Shortcuts' 3. Remove some debug message Modified Paths: -------------- trunk/qterm-qt4/src/CMakeLists.txt trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h Added Paths: ----------- trunk/qterm-qt4/src/shortcutsdialog.cpp trunk/qterm-qt4/src/shortcutsdialog.h trunk/qterm-qt4/src/ui/shortcutsdialog.ui Modified: trunk/qterm-qt4/src/CMakeLists.txt =================================================================== --- trunk/qterm-qt4/src/CMakeLists.txt 2008-11-24 21:39:32 UTC (rev 534) +++ trunk/qterm-qt4/src/CMakeLists.txt 2008-11-24 21:39:42 UTC (rev 535) @@ -32,6 +32,7 @@ ui_schemadialog.h ui_soundconf.h ui_sshlogin.h + ui_shortcutsdialog.h ui_zmodemdialog.h aboutdialog.cpp addrdialog.cpp @@ -68,6 +69,7 @@ qtermglobal.cpp quickdialog.cpp schemadialog.cpp + shortcutsdialog.cpp statusBar.cpp zmodemdialog.cpp hostinfo.cpp @@ -82,6 +84,7 @@ ui/prefdialog.ui ui/quickdialog.ui ui/schemadialog.ui + ui/shortcutsdialog.ui ui/soundconf.ui ui/sshlogin.ui ui/zmodemdialog.ui) Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:39:32 UTC (rev 534) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:39:42 UTC (rev 535) @@ -26,6 +26,7 @@ #include "keydialog.h" #include "trayicon.h" #include "imageviewer.h" +#include "shortcutsdialog.h" #include <QPaintEvent> #include <QMouseEvent> @@ -119,7 +120,7 @@ //initialize all settings iniSetting(); - loadShortcut(); + loadShortcuts(); initThemesMenu(); @@ -192,7 +193,7 @@ Global::instance()->saveGeometry(saveGeometry()); Global::instance()->saveState(saveState()); Global::instance()->saveConfig(); - saveShortcut(); + saveShortcuts(); } //addressbook @@ -975,6 +976,9 @@ m_reconnectAction->setObjectName("actionReconnect"); m_reconnectAction->setCheckable(true); + m_shortcutsAction = new QAction(tr("Configure Shortcuts..."),this); + m_shortcutsAction->setObjectName("actionShortcuts"); + connect(m_connectAction, SIGNAL(triggered()), this, SLOT(connectIt())); connect(m_disconnectAction, SIGNAL(triggered()), this, SLOT(disconnect())); connect(m_addressAction, SIGNAL(triggered()), this, SLOT(addressBook())); @@ -1025,6 +1029,7 @@ connect(m_homepageAction, SIGNAL(triggered()), this, SLOT(homepage())); connect(m_reconnectAction, SIGNAL(toggled(bool)), this, SLOT(reconnect(bool))); + connect(m_shortcutsAction, SIGNAL(triggered()), this, SLOT(configShortcuts())); } void Frame::addMainMenu() @@ -1106,6 +1111,8 @@ option->addSeparator(); option->addAction(m_defaultAction); option->addAction(m_prefAction); + option->addSeparator(); + option->addAction(m_shortcutsAction); // Special QMenu * spec = new QMenu(tr("&Special"), this); @@ -1366,18 +1373,17 @@ move(xp, yp); } -void Frame::saveShortcut() +void Frame::saveShortcuts() { Config * conf = Global::instance()->fileCfg(); QList<QAction*> actions = findChildren<QAction*>(QRegExp("action*")); - qDebug() << m_bossAction->shortcut().toString(); foreach (QAction* action, actions) { conf->setItemValue("Shortcut", action->objectName(), action->shortcut().toString()); } conf->save(); } -void Frame::loadShortcut() +void Frame::loadShortcuts() { Config * conf = Global::instance()->fileCfg(); QList<QAction*> actions = findChildren<QAction*>(QRegExp("action*")); @@ -1390,6 +1396,15 @@ } +void Frame::configShortcuts() +{ + QList<QAction*> actions = findChildren<QAction*>(QRegExp("action*")); + QList<QShortcut*> shortcutsList; + ShortcutsDialog sd(this,actions,shortcutsList); + sd.exec(); + saveShortcuts(); } +} + #include <qtermframe.moc> Modified: trunk/qterm-qt4/src/qtermframe.h =================================================================== --- trunk/qterm-qt4/src/qtermframe.h 2008-11-24 21:39:32 UTC (rev 534) +++ trunk/qterm-qt4/src/qtermframe.h 2008-11-24 21:39:42 UTC (rev 535) @@ -109,6 +109,8 @@ void switchWin(int); void paintEvent(QPaintEvent *); + + void configShortcuts(); public: QTabBar *tabBar; WndMgr * wndmgr; @@ -182,6 +184,7 @@ QAction * m_homepageAction; QAction * m_reconnectAction; + QAction * m_shortcutsAction; StatusBar * m_pStatusBar; @@ -205,8 +208,8 @@ void initShortcuts(); //void loadPref(Config *); void saveSetting(); - void saveShortcut(); - void loadShortcut(); + void saveShortcuts(); + void loadShortcuts(); void addMainMenu(); void addMainTool(); Added: trunk/qterm-qt4/src/shortcutsdialog.cpp =================================================================== --- trunk/qterm-qt4/src/shortcutsdialog.cpp (rev 0) +++ trunk/qterm-qt4/src/shortcutsdialog.cpp 2008-11-24 21:39:42 UTC (rev 535) @@ -0,0 +1,160 @@ +#include "shortcutsdialog.h" + +#include <QKeyEvent> +#include <QMessageBox> +#include <QShortcut> + +namespace QTerm { + +ShortcutsDialog::ShortcutsDialog(QWidget* parent, QList<QAction*> actions, QList<QShortcut*> shortcuts) + :QDialog(parent) +{ + setupUi(this); + editShortcut->installEventFilter(this); + buttonAssign->setEnabled(false); + connect(buttonAssign, SIGNAL(clicked()), this, SLOT(buttonAssignClicked())); + connect(buttonRemove, SIGNAL(clicked()), this, SLOT(buttonRemoveClicked())); + connect(buttonDone, SIGNAL(clicked()), this, SLOT(buttonDoneClicked())); + connect(editShortcut, SIGNAL(textChanged(const QString &)), this, SLOT(editShortcutTextChanged(const QString &))); + connect(tableWidget, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(tableWidgetCurrentCellChanged(int,int,int,int))); + + foreach(QAction* action, actions) { + //toolTip() gives text without '&' + QTableWidgetItem *itemAction = new QTableWidgetItem(action->toolTip()); + QString shortcut = action->shortcut().toString(); + QTableWidgetItem *itemShortcut = new QTableWidgetItem(shortcut); + listKeys << shortcut; + listActions << action; + int row = tableWidget->rowCount(); + tableWidget->insertRow(row); + tableWidget->setItem(row, 0, itemAction); + tableWidget->setItem(row, 1, itemShortcut); + } + foreach(QShortcut* shortcut, shortcuts) { + QTableWidgetItem *itemShortcut = new QTableWidgetItem(shortcut->objectName()); + QString key = shortcut->key().toString(); + QTableWidgetItem *itemKey = new QTableWidgetItem(key); + listKeys << key; + listActions << shortcut; + int row = tableWidget->rowCount(); + tableWidget->insertRow(row); + tableWidget->setItem(row, 0, itemShortcut); + tableWidget->setItem(row, 1, itemKey); + } + tableWidget->resizeColumnsToContents(); + tableWidget->setCurrentCell(0, 0); +} + +void ShortcutsDialog::buttonAssignClicked() +{ + QTableWidgetItem* item; + + int row = listKeys.indexOf(editShortcut->text()); + + if (row == tableWidget->currentRow()) + return; + + // already existed + if (row != -1) { + QObject* obj = listActions.at(row); + int aw = QMessageBox::warning(this, tr("Assign Shortcut"), + QString(tr("shortcut %1 is already assigned to %2\n" + "Do you want to clear and reassign?")) + .arg(editShortcut->text()) + .arg(getName(obj)), + QMessageBox::Yes, + QMessageBox::No | QMessageBox::Default); + if (aw == QMessageBox::No) + return; + // clear it + item = tableWidget->item(row, 1); + item->setText(""); + listKeys.replace(row, ""); + setKeySequence(obj, QKeySequence()); + } + // set it to the target action + row = tableWidget->currentRow(); + item = tableWidget->item(row, 1); + item->setText(editShortcut->text()); + listKeys.replace(row, editShortcut->text()); + setKeySequence(listActions.at(row), editShortcut->text()); +} + +void ShortcutsDialog::buttonRemoveClicked() +{ + int row = tableWidget->currentRow(); + // update table + QTableWidgetItem* item = tableWidget->item(row, 1); + item->setText(""); + // update listKeys + listKeys.replace(row, ""); + // update action + setKeySequence(listActions.at(row), QKeySequence()); +} + +void ShortcutsDialog::editShortcutTextChanged(const QString& shortcut) +{ + buttonAssign->setEnabled(!shortcut.isEmpty()); +} + +void ShortcutsDialog::buttonDoneClicked() +{ +} +void ShortcutsDialog::tableWidgetCurrentCellChanged(int row, int col, int, int) +{ + QTableWidgetItem *item = tableWidget->item(row, 1); + buttonRemove->setEnabled(!item->text().isEmpty()); +} +bool ShortcutsDialog::eventFilter(QObject *object, QEvent *event) +{ + if (object != editShortcut || event->type() != QEvent::KeyPress) + return false; + + QKeyEvent* keyevent = (QKeyEvent*)event; + int key = keyevent->key(); + Qt::KeyboardModifiers mod = keyevent->modifiers(); + + // dont accept Mdodifiers only + if (key == Qt::Key_Meta || key == Qt::Key_Alt || key == Qt::Key_AltGr + || key == Qt::Key_Shift || key == Qt::Key_Control) + return false; + // TODO: Shift+1 yields Shift+!, a bit confusing + // because Shift+1 is translated to Qt::Key, not raw scancode + // I dono how to do + QString text = ""; + if (mod != Qt::NoModifier) { + QKeySequence seqMod(mod); + text = seqMod.toString(QKeySequence::NativeText); + } + QKeySequence seqKey(key); + text += seqKey.toString(QKeySequence::NativeText); + + editShortcut->setText(text); + + return true; +} + +QString ShortcutsDialog::getName(QObject* obj) +{ + if (obj->inherits("QAction")) { + QAction* action = qobject_cast<QAction*>(obj); + return action->text(); + } else if (obj->inherits("QShortcut")) + return obj->objectName(); + return QString(); +} + +void ShortcutsDialog::setKeySequence(QObject* obj, QKeySequence key) +{ + if (obj->inherits("QAction")) { + QAction* action = qobject_cast<QAction*>(obj); + action->setShortcut(key); + } else if (obj->inherits("QShortcut")) { + QShortcut* shortcut = qobject_cast<QShortcut*>(obj); + shortcut->setKey(key); + } +} + +} + +#include "shortcutsdialog.moc" Added: trunk/qterm-qt4/src/shortcutsdialog.h =================================================================== --- trunk/qterm-qt4/src/shortcutsdialog.h (rev 0) +++ trunk/qterm-qt4/src/shortcutsdialog.h 2008-11-24 21:39:42 UTC (rev 535) @@ -0,0 +1,34 @@ +#ifndef SHORTCUTSDIALOG_H +#define SHORTCUTSDIALOG_H + +#include "ui_shortcutsdialog.h" +#include <QShortcut> + +namespace QTerm{ + +class ShortcutsDialog : public QDialog, public Ui_ShortcutsDialog +{ + Q_OBJECT +public: + ShortcutsDialog(QWidget*, QList<QAction*>, QList<QShortcut*>); + ~ShortcutsDialog() {} + +protected slots: + void buttonRemoveClicked(); + void buttonDoneClicked(); + void buttonAssignClicked(); + void editShortcutTextChanged(const QString&); + void tableWidgetCurrentCellChanged(int, int, int, int); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + QString getName(QObject*); + void setKeySequence(QObject*, QKeySequence); +private: + QList<QObject*> listActions; + QList<QString> listKeys; +}; + +} + +#endif //SHORTCUTSDIALOG_H Added: trunk/qterm-qt4/src/ui/shortcutsdialog.ui =================================================================== --- trunk/qterm-qt4/src/ui/shortcutsdialog.ui (rev 0) +++ trunk/qterm-qt4/src/ui/shortcutsdialog.ui 2008-11-24 21:39:42 UTC (rev 535) @@ -0,0 +1,152 @@ +<ui version="4.0" > + <class>ShortcutsDialog</class> + <widget class="QDialog" name="ShortcutsDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>588</width> + <height>447</height> + </rect> + </property> + <property name="focusPolicy" > + <enum>Qt::ClickFocus</enum> + </property> + <property name="contextMenuPolicy" > + <enum>Qt::NoContextMenu</enum> + </property> + <property name="windowTitle" > + <string>Shortcuts Dialog</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="2" column="0" colspan="2" > + <widget class="Line" name="line" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="0" column="0" colspan="2" > + <widget class="QTableWidget" name="tableWidget" > + <property name="editTriggers" > + <set>QAbstractItemView::NoEditTriggers</set> + </property> + <property name="selectionBehavior" > + <enum>QAbstractItemView::SelectRows</enum> + </property> + <property name="columnCount" > + <number>2</number> + </property> + <column> + <property name="text" > + <string>Actions</string> + </property> + </column> + <column> + <property name="text" > + <string>Shortcuts</string> + </property> + </column> + </widget> + </item> + <item row="1" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>61</width> + <height>23</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0" > + <widget class="QSplitter" name="splitter" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <widget class="QLabel" name="label" > + <property name="text" > + <string>Press any key here</string> + </property> + </widget> + <widget class="QLineEdit" name="editShortcut" /> + </widget> + </item> + <item row="3" column="0" colspan="2" > + <layout class="QHBoxLayout" > + <property name="spacing" > + <number>6</number> + </property> + <property name="margin" > + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="buttonAssign" > + <property name="text" > + <string>Assign</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonRemove" > + <property name="text" > + <string>Remove</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>181</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonDone" > + <property name="text" > + <string>Done</string> + </property> + <property name="default" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonDone</sender> + <signal>clicked()</signal> + <receiver>ShortcutsDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>369</x> + <y>253</y> + </hint> + <hint type="destinationlabel" > + <x>179</x> + <y>282</y> + </hint> + </hints> + </connection> + </connections> +</ui> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-24 22:55:46
|
Revision: 533 http://qterm.svn.sourceforge.net/qterm/?rev=533&view=rev Author: hephooey Date: 2008-11-24 21:39:27 +0000 (Mon, 24 Nov 2008) Log Message: ----------- Save and load shortcuts, also remove a unused function Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:39:21 UTC (rev 532) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:39:27 UTC (rev 533) @@ -118,6 +118,8 @@ //initialize all settings iniSetting(); + loadShortcut(); + initThemesMenu(); installEventFilter(this); @@ -189,6 +191,7 @@ Global::instance()->saveGeometry(saveGeometry()); Global::instance()->saveState(saveState()); Global::instance()->saveConfig(); + saveShortcut(); } //addressbook @@ -1222,15 +1225,6 @@ } } -QString Frame::valueToString(bool shown, int dock, int index, bool nl, int extra) -{ - QString str = ""; - - str = QString("%1 %2 %3 %4 %5").arg(shown ? 1 : 0).arg(dock).arg(index).arg(nl ? 1 : 0).arg(extra); - - return str; -} - void Frame::popupFocusIn(Window *) { // bring to font @@ -1370,6 +1364,31 @@ } move(xp, yp); } + +void Frame::saveShortcut() +{ + Config * conf = Global::instance()->fileCfg(); + QList<QAction*> actions = findChildren<QAction*>(QRegExp("action*")); + qDebug() << m_bossAction->shortcut().toString(); + foreach (QAction* action, actions) { + conf->setItemValue("Shortcut", action->objectName(), action->shortcut().toString()); + } + conf->save(); } +void Frame::loadShortcut() +{ + Config * conf = Global::instance()->fileCfg(); + QList<QAction*> actions = findChildren<QAction*>(QRegExp("action*")); + foreach(QAction* action, actions) + { + QString shortcut=conf->getItemValue("Shortcut", action->objectName()).toString(); + if (!shortcut.isEmpty()) + action->setShortcut(QKeySequence(shortcut)); + } + +} + +} + #include <qtermframe.moc> Modified: trunk/qterm-qt4/src/qtermframe.h =================================================================== --- trunk/qterm-qt4/src/qtermframe.h 2008-11-24 21:39:21 UTC (rev 532) +++ trunk/qterm-qt4/src/qtermframe.h 2008-11-24 21:39:27 UTC (rev 533) @@ -205,13 +205,14 @@ void initShortcuts(); //void loadPref(Config *); void saveSetting(); + void saveShortcut(); + void loadShortcut(); void addMainMenu(); void addMainTool(); void updateKeyToolBar(); - QString valueToString(bool, int, int, bool, int); QAction * insertThemeItem(const QString &); void setUseTray(bool); private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-24 22:55:53
|
Revision: 532 http://qterm.svn.sourceforge.net/qterm/?rev=532&view=rev Author: hephooey Date: 2008-11-24 21:39:21 +0000 (Mon, 24 Nov 2008) Log Message: ----------- Switch to more flexible get/setItemValue functions. TODO: Clean up the conversion code. Modified Paths: -------------- trunk/qterm-qt4/src/addrdialog.cpp trunk/qterm-qt4/src/keydialog.cpp trunk/qterm-qt4/src/prefdialog.cpp trunk/qterm-qt4/src/qtermcanvas.cpp trunk/qterm-qt4/src/qtermconfig.cpp trunk/qterm-qt4/src/qtermconfig.h trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermhttp.cpp trunk/qterm-qt4/src/qtermscreen.cpp trunk/qterm-qt4/src/qtermwindow.cpp trunk/qterm-qt4/src/qtermzmodem.cpp trunk/qterm-qt4/src/quickdialog.cpp trunk/qterm-qt4/src/schemadialog.cpp Modified: trunk/qterm-qt4/src/addrdialog.cpp =================================================================== --- trunk/qterm-qt4/src/addrdialog.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/addrdialog.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -115,7 +115,7 @@ { QString strTmp; Config * pConf = Global::instance()->addrCfg(); - strTmp = pConf->getItemValue("bbs list", "num"); + strTmp = pConf->getItemValue("bbs list", "num").toString(); int num = strTmp.toInt(); int index = ui.nameListWidget->currentRow(); @@ -145,7 +145,7 @@ { QString strTmp; Config * pConf = Global::instance()->addrCfg(); - strTmp = pConf->getItemValue("bbs list", "num"); + strTmp = pConf->getItemValue("bbs list", "num").toString(); int num = strTmp.toInt(); if(ui.nameListWidget->count()==0) Modified: trunk/qterm-qt4/src/keydialog.cpp =================================================================== --- trunk/qterm-qt4/src/keydialog.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/keydialog.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -71,7 +71,7 @@ void keyDialog::onAdd() { - QString strTmp = pConf->getItemValue("key", "num"); + QString strTmp = pConf->getItemValue("key", "num").toString(); int num = strTmp.toInt(); strTmp.setNum(num+1); @@ -102,7 +102,7 @@ void keyDialog::onDelete() { - QString strTmp = pConf->getItemValue("key", "num"); + QString strTmp = pConf->getItemValue("key", "num").toString(); int num = strTmp.toInt(); if(num==0) return; @@ -225,12 +225,12 @@ void keyDialog::loadName() { - QString strTmp = pConf->getItemValue("key", "num"); + QString strTmp = pConf->getItemValue("key", "num").toString(); int num = strTmp.toInt(); for(int i=0; i<num; i++) { strTmp = QString("name%1").arg(i); - ui.nameListWidget->addItem(pConf->getItemValue("key", strTmp)); + ui.nameListWidget->addItem(pConf->getItemValue("key", strTmp).toString()); } if(num>0) ui.nameListWidget->setCurrentRow(0); @@ -243,16 +243,16 @@ void keyDialog::loadKey(int n) { - QString strTmp = pConf->getItemValue("key", "num"); + QString strTmp = pConf->getItemValue("key", "num").toString(); if(n>=strTmp.toInt()) return; QString strItem; strItem = QString("name%1").arg(n); - ui.nameEdit->setText(pConf->getItemValue("key", strItem)); + ui.nameEdit->setText(pConf->getItemValue("key", strItem).toString()); strItem = QString("key%1").arg(n); - strTmp = pConf->getItemValue("key", strItem); + strTmp = pConf->getItemValue("key", strItem).toString(); if(strTmp[0]=='0') { ui.keyEdit->setText(strTmp.mid(1)); Modified: trunk/qterm-qt4/src/prefdialog.cpp =================================================================== --- trunk/qterm-qt4/src/prefdialog.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/prefdialog.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -64,53 +64,53 @@ QString strTmp; - strTmp = conf->getItemValue("preference","xim"); + strTmp = conf->getItemValue("preference","xim").toString(); ui.ximComboBox->setCurrentIndex(strTmp.toInt()); - strTmp = conf->getItemValue("preference","wordwrap"); + strTmp = conf->getItemValue("preference","wordwrap").toString(); ui.wordSpinBox->setValue(strTmp.toInt()); - strTmp = conf->getItemValue("preference","wheel"); + strTmp = conf->getItemValue("preference","wheel").toString(); ui.wheelCheckBox->setChecked(strTmp!="0"); - strTmp = conf->getItemValue("preference","url"); + strTmp = conf->getItemValue("preference","url").toString(); ui.urlCheckBox->setChecked(strTmp!="0"); - strTmp = conf->getItemValue("preference","blinktab"); + strTmp = conf->getItemValue("preference","blinktab").toString(); ui.blinkCheckBox->setChecked(strTmp!="0"); - strTmp = conf->getItemValue("preference","warn"); + strTmp = conf->getItemValue("preference","warn").toString(); ui.warnCheckBox->setChecked(strTmp!="0"); - strTmp = conf->getItemValue("preference","wavefile"); + strTmp = conf->getItemValue("preference","wavefile").toString(); ui.wavefileLineEdit->setText( strTmp ); - strTmp = conf->getItemValue("preference","externalplayer"); + strTmp = conf->getItemValue("preference","externalplayer").toString(); ui.playerLineEdit->setText( strTmp ); - strTmp = conf->getItemValue("preference","antialias"); + strTmp = conf->getItemValue("preference","antialias").toString(); ui.aacheckBox->setChecked( strTmp!="0" ); - strTmp = conf->getItemValue("preference","tray"); + strTmp = conf->getItemValue("preference","tray").toString(); ui.trayCheckBox->setChecked( strTmp!="0" ); - strTmp = conf->getItemValue("preference","clearpool"); + strTmp = conf->getItemValue("preference","clearpool").toString(); ui.clearCheckBox->setChecked( strTmp!="0" ); - strTmp = conf->getItemValue("preference","pool"); + strTmp = conf->getItemValue("preference","pool").toString(); if(strTmp.isEmpty()) strTmp = Global::instance()->pathCfg()+"pool/"; ui.poolLineEdit->setText( strTmp ); - strTmp = conf->getItemValue("preference","http"); + strTmp = conf->getItemValue("preference","http").toString(); ui.httpLineEdit->setText( strTmp ); - strTmp = conf->getItemValue("preference","zmodem"); + strTmp = conf->getItemValue("preference","zmodem").toString(); if(strTmp.isEmpty()) strTmp = Global::instance()->pathCfg()+"zmodem/"; ui.zmodemLineEdit->setText( strTmp ); - strTmp = conf->getItemValue("preference","image"); + strTmp = conf->getItemValue("preference","image").toString(); ui.imageLineEdit->setText( strTmp ); } Modified: trunk/qterm-qt4/src/qtermcanvas.cpp =================================================================== --- trunk/qterm-qt4/src/qtermcanvas.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermcanvas.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -203,7 +203,7 @@ void Canvas::silentCopy() { // save it to $savefiledialog - QString strPath = Global::instance()->fileCfg()->getItemValue("global","savefiledialog"); + QString strPath = Global::instance()->fileCfg()->getItemValue("global","savefiledialog").toString(); QFileInfo fi(strFileName); QString strSave = strPath+"/"+fi.fileName(); Modified: trunk/qterm-qt4/src/qtermconfig.cpp =================================================================== --- trunk/qterm-qt4/src/qtermconfig.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermconfig.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -97,14 +97,6 @@ } bool Config::setItemValue(const QString & szSection, - const QString & szItemName, const QString & szItemValue) -{ - QString key = szSection+"/"+szItemName; - m_settings->setValue(key, szItemValue); - return checkError(); -} - -bool Config::setItemValueNew(const QString & szSection, const QString & szItemName, const QVariant & szItemValue) { QString key = szSection+"/"+szItemName; @@ -112,21 +104,10 @@ return checkError(); } -QString Config::getItemValue(const QString & szSection, const QString & szItemName) +QVariant Config::getItemValue(const QString & szSection, const QString & szItemName) { QString key = szSection+"/"+szItemName; QVariant data = m_settings->value(key); - if (data.isValid()) { - return data.toString(); - } else { - return ""; - } -} - -QVariant Config::getItemValueNew(const QString & szSection, const QString & szItemName) -{ - QString key = szSection+"/"+szItemName; - QVariant data = m_settings->value(key); return data; } Modified: trunk/qterm-qt4/src/qtermconfig.h =================================================================== --- trunk/qterm-qt4/src/qtermconfig.h 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermconfig.h 2008-11-24 21:39:21 UTC (rev 532) @@ -17,10 +17,8 @@ bool save(const QString & szFileName = ""); - bool setItemValue(const QString & szSection, const QString & szItemName,const QString & szItemValue); - bool setItemValueNew(const QString & szSection, const QString & szItemName,const QVariant & szItemValue); - QString getItemValue(const QString & szSection, const QString & szItemName); - QVariant getItemValueNew(const QString & szSection, const QString & szItemName); + bool setItemValue(const QString & szSection, const QString & szItemName,const QVariant & szItemValue); + QVariant getItemValue(const QString & szSection, const QString & szItemName); bool deleteItem(const QString & szSection, const QString & szItemName); bool deleteSection(const QString & szSection); Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -709,7 +709,7 @@ QString strItem = QString("key%1").arg(id); - QString strTmp = conf->getItemValue("key", strItem); + QString strTmp = conf->getItemValue("key", strItem).toString(); if (strTmp[0] == '0') { // key wndmgr->activeWindow()->externInput(strTmp.mid(1).toLatin1()); @@ -902,7 +902,7 @@ m_fullAction->setShortcut(Qt::Key_F6); addAction(m_fullAction); m_bossAction = new QAction(tr("Boss &Color"), this); - m_bossAction->setObjectName("action Boss"); + m_bossAction->setObjectName("actionBoss"); m_bossAction->setShortcut(Qt::Key_F12); QActionGroup * scrollGroup = new QActionGroup(this); @@ -1203,18 +1203,18 @@ Config * conf = Global::instance()->fileCfg(); QString strItem, strTmp; - strTmp = conf->getItemValue("key", "num"); + strTmp = conf->getItemValue("key", "num").toString(); int num = strTmp.toInt(); for (int i = 0; i < num; i++) { strItem = QString("name%1").arg(i); - strTmp = conf->getItemValue("key", strItem); + strTmp = conf->getItemValue("key", strItem).toString(); ToolButton *button = new ToolButton(key, i, strTmp); // button->setUsesTextLabel(true); button->setText(strTmp); // button->setTextPosition(QToolButton::BesideIcon); strItem = QString("key%1").arg(i); - strTmp = (conf->getItemValue("key", strItem)); + strTmp = (conf->getItemValue("key", strItem).toString()); // QToolTip::add( button, strTmp.mid(1) ); // button->addToolTip(strTmp.mid(1)); connect(button, SIGNAL(buttonClicked(int)), this, SLOT(keyClicked(int))); Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -118,13 +118,13 @@ { QStringList listName; - QString strTmp = m_address->getItemValue("bbs list", "num"); + QString strTmp = m_address->getItemValue("bbs list", "num").toString(); QString strSection; for (int i = 0; i < strTmp.toInt(); i++) { strSection.sprintf("bbs %d", i); - listName.append(m_address->getItemValue(strSection, "name")); + listName.append(m_address->getItemValue(strSection, "name").toString()); } return listName; @@ -139,89 +139,89 @@ strSection.sprintf("bbs %d", n); // check if larger than existence - strTmp = m_address->getItemValue("bbs list", "num"); + strTmp = m_address->getItemValue("bbs list", "num").toString(); if (n >= strTmp.toInt()) return false; - param.m_strName = m_address->getItemValue(strSection, "name"); - param.m_strAddr = m_address->getItemValue(strSection, "addr"); - strTmp = m_address->getItemValue(strSection, "port"); + param.m_strName = m_address->getItemValue(strSection, "name").toString(); + param.m_strAddr = m_address->getItemValue(strSection, "addr").toString(); + strTmp = m_address->getItemValue(strSection, "port").toString(); param.m_uPort = strTmp.toUShort(); - strTmp = m_address->getItemValue(strSection, "hosttype"); + strTmp = m_address->getItemValue(strSection, "hosttype").toString(); param.m_nHostType = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "autologin"); + strTmp = m_address->getItemValue(strSection, "autologin").toString(); param.m_bAutoLogin = (strTmp != "0"); - param.m_strPreLogin = m_address->getItemValue(strSection, "prelogin"); - param.m_strUser = m_address->getItemValue(strSection, "user"); - param.m_strPasswd = m_address->getItemValue(strSection, "password"); - param.m_strPostLogin = m_address->getItemValue(strSection, "postlogin"); + param.m_strPreLogin = m_address->getItemValue(strSection, "prelogin").toString(); + param.m_strUser = m_address->getItemValue(strSection, "user").toString(); + param.m_strPasswd = m_address->getItemValue(strSection, "password").toString(); + param.m_strPostLogin = m_address->getItemValue(strSection, "postlogin").toString(); - strTmp = m_address->getItemValue(strSection, "bbscode"); + strTmp = m_address->getItemValue(strSection, "bbscode").toString(); param.m_nBBSCode = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "displaycode"); + strTmp = m_address->getItemValue(strSection, "displaycode").toString(); param.m_nDispCode = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "autofont"); + strTmp = m_address->getItemValue(strSection, "autofont").toString(); param.m_bAutoFont = (strTmp != "0"); - strTmp = m_address->getItemValue(strSection, "alwayshighlight"); + strTmp = m_address->getItemValue(strSection, "alwayshighlight").toString(); param.m_bAlwaysHighlight = (strTmp != "0"); - strTmp = m_address->getItemValue(strSection, "ansicolor"); + strTmp = m_address->getItemValue(strSection, "ansicolor").toString(); param.m_bAnsiColor = (strTmp != "0"); - param.m_strFontName = m_address->getItemValue(strSection, "fontname"); - strTmp = m_address->getItemValue(strSection, "fontsize"); + param.m_strFontName = m_address->getItemValue(strSection, "fontname").toString(); + strTmp = m_address->getItemValue(strSection, "fontsize").toString(); param.m_nFontSize = strTmp.toInt(); - param.m_clrFg.setNamedColor(m_address->getItemValue(strSection, "fgcolor")); - param.m_clrBg.setNamedColor(m_address->getItemValue(strSection, "bgcolor")); - param.m_strSchemaFile = m_address->getItemValue(strSection, "schemafile"); + param.m_clrFg.setNamedColor(m_address->getItemValue(strSection, "fgcolor").toString()); + param.m_clrBg.setNamedColor(m_address->getItemValue(strSection, "bgcolor").toString()); + param.m_strSchemaFile = m_address->getItemValue(strSection, "schemafile").toString(); - param.m_strTerm = m_address->getItemValue(strSection, "termtype"); - strTmp = m_address->getItemValue(strSection, "keytype"); + param.m_strTerm = m_address->getItemValue(strSection, "termtype").toString(); + strTmp = m_address->getItemValue(strSection, "keytype").toString(); param.m_nKey = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "column"); + strTmp = m_address->getItemValue(strSection, "column").toString(); param.m_nCol = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "row"); + strTmp = m_address->getItemValue(strSection, "row").toString(); param.m_nRow = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "scroll"); + strTmp = m_address->getItemValue(strSection, "scroll").toString(); param.m_nScrollLines = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "cursor"); + strTmp = m_address->getItemValue(strSection, "cursor").toString(); param.m_nCursorType = strTmp.toInt(); - param.m_strEscape = m_address->getItemValue(strSection, "escape"); + param.m_strEscape = m_address->getItemValue(strSection, "escape").toString(); - strTmp = m_address->getItemValue(strSection, "proxytype"); + strTmp = m_address->getItemValue(strSection, "proxytype").toString(); param.m_nProxyType = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "proxyauth"); + strTmp = m_address->getItemValue(strSection, "proxyauth").toString(); param.m_bAuth = (strTmp != "0"); - param.m_strProxyHost = m_address->getItemValue(strSection, "proxyaddr"); - strTmp = m_address->getItemValue(strSection, "proxyport"); + param.m_strProxyHost = m_address->getItemValue(strSection, "proxyaddr").toString(); + strTmp = m_address->getItemValue(strSection, "proxyport").toString(); param.m_uProxyPort = strTmp.toInt(); - param.m_strProxyUser = m_address->getItemValue(strSection, "proxyuser"); - param.m_strProxyPasswd = m_address->getItemValue(strSection, "proxypassword"); - strTmp = m_address->getItemValue(strSection, "protocol"); + param.m_strProxyUser = m_address->getItemValue(strSection, "proxyuser").toString(); + param.m_strProxyPasswd = m_address->getItemValue(strSection, "proxypassword").toString(); + strTmp = m_address->getItemValue(strSection, "protocol").toString(); param.m_nProtocolType = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "maxidle"); + strTmp = m_address->getItemValue(strSection, "maxidle").toString(); param.m_nMaxIdle = strTmp.toInt(); - param.m_strReplyKey = m_address->getItemValue(strSection, "replykey"); + param.m_strReplyKey = m_address->getItemValue(strSection, "replykey").toString(); if (param.m_strReplyKey.isNull()) qDebug("loading null\n"); - param.m_strAntiString = m_address->getItemValue(strSection, "antiidlestring"); - param.m_strAutoReply = m_address->getItemValue(strSection, "autoreply"); - strTmp = m_address->getItemValue(strSection, "bautoreply"); + param.m_strAntiString = m_address->getItemValue(strSection, "antiidlestring").toString(); + param.m_strAutoReply = m_address->getItemValue(strSection, "autoreply").toString(); + strTmp = m_address->getItemValue(strSection, "bautoreply").toString(); param.m_bAutoReply = (strTmp != "0"); - strTmp = m_address->getItemValue(strSection, "reconnect"); + strTmp = m_address->getItemValue(strSection, "reconnect").toString(); param.m_bReconnect = (strTmp != "0"); - strTmp = m_address->getItemValue(strSection, "interval"); + strTmp = m_address->getItemValue(strSection, "interval").toString(); param.m_nReconnectInterval = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "retrytimes"); + strTmp = m_address->getItemValue(strSection, "retrytimes").toString(); param.m_nRetry = strTmp.toInt(); - strTmp = m_address->getItemValue(strSection, "loadscript"); + strTmp = m_address->getItemValue(strSection, "loadscript").toString(); param.m_bLoadScript = (strTmp != "0"); - param.m_strScriptFile = m_address->getItemValue(strSection, "scriptfile"); + param.m_strScriptFile = m_address->getItemValue(strSection, "scriptfile").toString(); - strTmp = m_address->getItemValue(strSection, "menutype"); + strTmp = m_address->getItemValue(strSection, "menutype").toString(); param.m_nMenuType = strTmp.toInt(); - param.m_clrMenu.setNamedColor(m_address->getItemValue(strSection, "menucolor")); + param.m_clrMenu.setNamedColor(m_address->getItemValue(strSection, "menucolor").toString()); return true; } @@ -309,47 +309,47 @@ void Global::loadPrefence() { QString strTmp; - strTmp = m_config->getItemValue("preference", "xim"); + strTmp = m_config->getItemValue("preference", "xim").toString(); m_pref.nXIM = strTmp.toInt() == 0 ? GBK : Big5; - strTmp = m_config->getItemValue("preference", "wordwrap"); + strTmp = m_config->getItemValue("preference", "wordwrap").toString(); m_pref.nWordWrap = strTmp.toInt(); - strTmp = m_config->getItemValue("preference", "wheel"); + strTmp = m_config->getItemValue("preference", "wheel").toString(); m_pref.bWheel = (strTmp != "0"); - strTmp = m_config->getItemValue("preference", "url"); + strTmp = m_config->getItemValue("preference", "url").toString(); m_pref.bUrl = (strTmp != "0"); - strTmp = m_config->getItemValue("preference", "blinktab"); + strTmp = m_config->getItemValue("preference", "blinktab").toString(); m_pref.bBlinkTab = (strTmp != "0"); - strTmp = m_config->getItemValue("preference", "warn"); + strTmp = m_config->getItemValue("preference", "warn").toString(); m_pref.bWarn = (strTmp != "0"); - strTmp = m_config->getItemValue("preference", "beep"); + strTmp = m_config->getItemValue("preference", "beep").toString(); m_pref.nBeep = strTmp.toInt(); - m_pref.strWave = m_config->getItemValue("preference", "wavefile"); - strTmp = m_config->getItemValue("preference", "http"); + m_pref.strWave = m_config->getItemValue("preference", "wavefile").toString(); + strTmp = m_config->getItemValue("preference", "http").toString(); m_pref.strHttp = strTmp; - strTmp = m_config->getItemValue("preference", "antialias"); + strTmp = m_config->getItemValue("preference", "antialias").toString(); m_pref.bAA = (strTmp != "0"); - strTmp = m_config->getItemValue("preference", "tray"); + strTmp = m_config->getItemValue("preference", "tray").toString(); m_pref.bTray = (strTmp != "0"); - strTmp = m_config->getItemValue("preference", "externalplayer"); + strTmp = m_config->getItemValue("preference", "externalplayer").toString(); m_pref.strPlayer = strTmp; - strTmp = m_config->getItemValue("preference", "clearpool"); + strTmp = m_config->getItemValue("preference", "clearpool").toString(); m_pref.bClearPool = (strTmp != "0"); - strTmp = m_config->getItemValue("preference", "pool"); + strTmp = m_config->getItemValue("preference", "pool").toString(); m_pref.strPoolPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "pool/" : strTmp; if (m_pref.strPoolPath.right(1) != "/") m_pref.strPoolPath.append('/'); - strTmp = m_config->getItemValue("preference", "zmodem"); + strTmp = m_config->getItemValue("preference", "zmodem").toString(); m_pref.strZmPath = strTmp.isEmpty() ? Global::instance()->pathCfg() + "zmodem/" : strTmp; if (m_pref.strZmPath.right(1) != "/") m_pref.strZmPath.append('/'); - strTmp = m_config->getItemValue("preference", "image"); + strTmp = m_config->getItemValue("preference", "image").toString(); m_pref.strImageViewer = strTmp; } QString Global::getOpenFileName(const QString & filter, QWidget * widget) { - QString path = m_config->getItemValue("global", "openfiledialog"); + QString path = m_config->getItemValue("global", "openfiledialog").toString(); QString strOpen = QFileDialog::getOpenFileName(widget, "choose a file", path, filter); @@ -367,7 +367,7 @@ QString Global::getSaveFileName(const QString& filename, QWidget* widget) { // get the previous dir - QString path = m_config->getItemValue("global", "savefiledialog"); + QString path = m_config->getItemValue("global", "savefiledialog").toString(); QString strSave = QFileDialog::getSaveFileName(widget, "Choose a file to save under", path + "/" + filename, "*"); @@ -494,7 +494,7 @@ bool Global::iniSettings() { //install the translator - QString lang = m_config->getItemValue("global", "language"); + QString lang = m_config->getItemValue("global", "language").toString(); if (lang != "eng" && !lang.isEmpty()) { // look in $HOME/.qterm/po/ first QString qm = QDir::homePath() + "/.qterm/po/qterm_" + lang + ".qm"; @@ -505,9 +505,9 @@ qApp->installTranslator(translator); } //set font - QString family = m_config->getItemValue("global", "font"); - QString pointsize = m_config->getItemValue("global", "pointsize"); - QString pixelsize = m_config->getItemValue("global", "pixelsize"); + QString family = m_config->getItemValue("global", "font").toString(); + QString pointsize = m_config->getItemValue("global", "pointsize").toString(); + QString pixelsize = m_config->getItemValue("global", "pixelsize").toString(); if (!family.isEmpty()) { QFont font(family); if (pointsize.toInt() > 0) @@ -515,7 +515,7 @@ if (pixelsize.toInt() > 0) font.setPixelSize(pixelsize.toInt()); #if (QT_VERSION>=300) - QString bAA = m_config->getItemValue("global", "antialias"); + QString bAA = m_config->getItemValue("global", "antialias").toString(); if (bAA != "0") font.setStyleStrategy(QFont::PreferAntialias); #endif @@ -523,13 +523,13 @@ } // zmodem and pool directory - QString pathZmodem = m_config->getItemValue("preference", "zmodem"); + QString pathZmodem = m_config->getItemValue("preference", "zmodem").toString(); if (pathZmodem.isEmpty()) pathZmodem = m_pathCfg + "zmodem"; if (!isPathExist(pathZmodem)) return false; - QString pathPool = m_config->getItemValue("preference", "pool"); + QString pathPool = m_config->getItemValue("preference", "pool").toString(); if (pathPool.isEmpty()) pathPool = m_pathCfg + "pool/"; @@ -674,7 +674,7 @@ void Global::loadConfig() { QString strTmp; - strTmp = m_config->getItemValue("global", "fullscreen"); + strTmp = m_config->getItemValue("global", "fullscreen").toString(); if (strTmp == "1") { setFullScreen(true); @@ -682,18 +682,18 @@ setFullScreen(false); } - setStyle(m_config->getItemValue("global", "theme")); + setStyle(m_config->getItemValue("global", "theme").toString()); setEscapeString(""); - strTmp = m_config->getItemValue("global", "clipcodec"); + strTmp = m_config->getItemValue("global", "clipcodec").toString(); if (strTmp == "0") { setClipCodec(Global::GBK); } else { setClipCodec(Global::Big5); } - strTmp = m_config->getItemValue("global", "vscrollpos"); + strTmp = m_config->getItemValue("global", "vscrollpos").toString(); if (strTmp == "0") { setScrollPosition(Global::Hide); } else if (strTmp == "1") { @@ -702,10 +702,10 @@ setScrollPosition(Global::Right); } - strTmp = m_config->getItemValue("global", "statusbar"); + strTmp = m_config->getItemValue("global", "statusbar").toString(); setStatusBar((strTmp != "0")); - strTmp = m_config->getItemValue("global", "switchbar"); + strTmp = m_config->getItemValue("global", "switchbar").toString(); setSwitchBar((strTmp != "0")); setBossColor(false); @@ -749,22 +749,22 @@ QByteArray Global::loadGeometry() { - return m_config->getItemValueNew("global","geometry").toByteArray(); + return m_config->getItemValue("global","geometry").toByteArray(); } QByteArray Global::loadState() { - return m_config->getItemValueNew("global","state").toByteArray(); + return m_config->getItemValue("global","state").toByteArray(); } void Global::saveGeometry(const QByteArray geometry) { - m_config->setItemValueNew("global", "geometry", geometry); + m_config->setItemValue("global", "geometry", geometry); } void Global::saveState(const QByteArray state) { - m_config->setItemValueNew("global", "state", state); + m_config->setItemValue("global", "state", state); } void Global::cleanup() Modified: trunk/qterm-qt4/src/qtermhttp.cpp =================================================================== --- trunk/qterm-qt4/src/qtermhttp.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermhttp.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -75,7 +75,7 @@ if(QFile::exists(Global::instance()->pathCfg()+"hosts.cfg")) { Config conf(Global::instance()->pathCfg()+"hosts.cfg"); - QString strTmp = conf.getItemValue("hosts",u.host()); + QString strTmp = conf.getItemValue("hosts",u.host()).toString(); if(!strTmp.isEmpty()) { QString strUrl = url; @@ -221,7 +221,7 @@ void Http::previewImage(const QString& filename) { - QString strViewer = Global::instance()->fileCfg()->getItemValue("preference","image"); + QString strViewer = Global::instance()->fileCfg()->getItemValue("preference","image").toString(); if(strViewer.isEmpty()) { Modified: trunk/qterm-qt4/src/qtermscreen.cpp =================================================================== --- trunk/qterm-qt4/src/qtermscreen.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermscreen.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -465,37 +465,37 @@ // printf("schema %s loaded sucessfully\n", m_pParam->m_strSchemaFile); Config *pConf = new Config(m_pParam->m_strSchemaFile); - m_color[0].setNamedColor(pConf->getItemValue("color","color0")); - m_color[1].setNamedColor(pConf->getItemValue("color","color1")); - m_color[2].setNamedColor(pConf->getItemValue("color","color2")); - m_color[3].setNamedColor(pConf->getItemValue("color","color3")); - m_color[4].setNamedColor(pConf->getItemValue("color","color4")); - m_color[5].setNamedColor(pConf->getItemValue("color","color5")); - m_color[6].setNamedColor(pConf->getItemValue("color","color6")); - m_color[7].setNamedColor(pConf->getItemValue("color","color7")); - m_color[8].setNamedColor(pConf->getItemValue("color","color8")); - m_color[9].setNamedColor(pConf->getItemValue("color","color9")); - m_color[10].setNamedColor(pConf->getItemValue("color","color10")); - m_color[11].setNamedColor(pConf->getItemValue("color","color11")); - m_color[12].setNamedColor(pConf->getItemValue("color","color12")); - m_color[13].setNamedColor(pConf->getItemValue("color","color13")); - m_color[14].setNamedColor(pConf->getItemValue("color","color14")); - m_color[15].setNamedColor(pConf->getItemValue("color","color15")); + m_color[0].setNamedColor(pConf->getItemValue("color","color0").toString()); + m_color[1].setNamedColor(pConf->getItemValue("color","color1").toString()); + m_color[2].setNamedColor(pConf->getItemValue("color","color2").toString()); + m_color[3].setNamedColor(pConf->getItemValue("color","color3").toString()); + m_color[4].setNamedColor(pConf->getItemValue("color","color4").toString()); + m_color[5].setNamedColor(pConf->getItemValue("color","color5").toString()); + m_color[6].setNamedColor(pConf->getItemValue("color","color6").toString()); + m_color[7].setNamedColor(pConf->getItemValue("color","color7").toString()); + m_color[8].setNamedColor(pConf->getItemValue("color","color8").toString()); + m_color[9].setNamedColor(pConf->getItemValue("color","color9").toString()); + m_color[10].setNamedColor(pConf->getItemValue("color","color10").toString()); + m_color[11].setNamedColor(pConf->getItemValue("color","color11").toString()); + m_color[12].setNamedColor(pConf->getItemValue("color","color12").toString()); + m_color[13].setNamedColor(pConf->getItemValue("color","color13").toString()); + m_color[14].setNamedColor(pConf->getItemValue("color","color14").toString()); + m_color[15].setNamedColor(pConf->getItemValue("color","color15").toString()); // bg type - QString strTmp = pConf->getItemValue("image", "type"); + QString strTmp = pConf->getItemValue("image", "type").toString(); m_nPxmType = strTmp.toInt(); // fade effect QColor fadecolor; - fadecolor.setNamedColor(pConf->getItemValue("image","fade")); - strTmp = pConf->getItemValue("image", "alpha"); + fadecolor.setNamedColor(pConf->getItemValue("image","fade").toString()); + strTmp = pConf->getItemValue("image", "alpha").toString(); float alpha = strTmp.toFloat(); // get the image name - if(QFile::exists(pConf->getItemValue("image","name")) && m_nPxmType>1) // valid image name and type + if(QFile::exists(pConf->getItemValue("image","name").toString()) && m_nPxmType>1) // valid image name and type { - m_pxmBg = QPixmap(pConf->getItemValue("image","name")); + m_pxmBg = QPixmap(pConf->getItemValue("image","name").toString()); QImage ima(m_pxmBg.toImage()); ima = fade(ima, alpha, fadecolor); m_pxmBg = QPixmap::fromImage(ima); Modified: trunk/qterm-qt4/src/qtermwindow.cpp =================================================================== --- trunk/qterm-qt4/src/qtermwindow.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermwindow.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -1527,7 +1527,7 @@ void Window::viewMessages( ) { msgDialog msg(this); - const char * size = Global::instance()->fileCfg()->getItemValue("global","msgdialog").toLatin1(); + const char * size = Global::instance()->fileCfg()->getItemValue("global","msgdialog").toString().toLatin1(); if(size!=NULL) { int x,y,cx,cy; @@ -1669,7 +1669,7 @@ if( e == DAE_FINISH ) { articleDialog article(this); - const char * size = Global::instance()->fileCfg()->getItemValue("global","articledialog").toLatin1().data(); + const char * size = Global::instance()->fileCfg()->getItemValue("global","articledialog").toString().toLatin1().data(); if(size!=NULL) { int x,y,cx,cy; Modified: trunk/qterm-qt4/src/qtermzmodem.cpp =================================================================== --- trunk/qterm-qt4/src/qtermzmodem.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/qtermzmodem.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -530,7 +530,7 @@ info->timeout = 60 ; - QString path = Global::instance()->fileCfg()->getItemValue("global","openfiledialog"); + QString path = Global::instance()->fileCfg()->getItemValue("global","openfiledialog").toString(); strFileList = QFileDialog::getOpenFileNames(0, "Choose the files", path, "All files(*)"); if(strFileList.count()!=0) { Modified: trunk/qterm-qt4/src/quickdialog.cpp =================================================================== --- trunk/qterm-qt4/src/quickdialog.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/quickdialog.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -61,12 +61,12 @@ void quickDialog::loadHistory() { - QString strTmp = pConf->getItemValue("quick list", "num" ); + QString strTmp = pConf->getItemValue("quick list", "num" ).toString(); QString strSection; for( int i=0; i<strTmp.toInt(); i++ ) { strSection = QString("quick %1").arg(i); - ui.historyComboBox->addItem( pConf->getItemValue( strSection.toLatin1(), "addr" ) ); + ui.historyComboBox->addItem( pConf->getItemValue( strSection.toLatin1(), "addr" ).toString() ); } if(strTmp != "0") @@ -88,21 +88,21 @@ void quickDialog::listChanged( int index ) { - QString strTmp = pConf->getItemValue("quick list", "num" ); + QString strTmp = pConf->getItemValue("quick list", "num" ).toString(); if(strTmp=="0") return; QString strSection = QString("quick %1").arg(index); // cstrSection.sprintf("quick %d", index); - ui.addrLineEdit->setText( pConf->getItemValue( strSection, "addr" ) ); - ui.portLineEdit->setText( pConf->getItemValue( strSection, "port" ) ); + ui.addrLineEdit->setText( pConf->getItemValue( strSection, "addr" ).toString() ); + ui.portLineEdit->setText( pConf->getItemValue( strSection, "port" ).toString() ); } void quickDialog::addAddr() { QString strTmp; - strTmp = Global::instance()->addrCfg()->getItemValue("bbs list", "num"); + strTmp = Global::instance()->addrCfg()->getItemValue("bbs list", "num").toString(); int num = strTmp.toInt(); strTmp.setNum(num+1); @@ -118,7 +118,7 @@ { int n = ui.historyComboBox->currentIndex(); - QString strTmp = pConf->getItemValue("quick list", "num"); + QString strTmp = pConf->getItemValue("quick list", "num").toString(); int num = strTmp.toInt(); if( num!=0 && n!=-1 ) @@ -140,7 +140,7 @@ pConf->renameSection( strTmp.toLatin1(), strSection.toLatin1() ); } - strTmp = pConf->getItemValue("quick list", "num" ); + strTmp = pConf->getItemValue("quick list", "num" ).toString(); strTmp.setNum( qMax(0,strTmp.toInt()-1) ); pConf->setItemValue("quick list", "num", strTmp.toLatin1()); @@ -190,7 +190,7 @@ return; } - QString strTmp = pConf->getItemValue("quick list", "num"); + QString strTmp = pConf->getItemValue("quick list", "num").toString(); int num = strTmp.toInt(); bool bExist=false; @@ -201,10 +201,10 @@ { strSection = QString("quick %1").arg(i); - strTmp = pConf->getItemValue(strSection.toLatin1(), "addr"); + strTmp = pConf->getItemValue(strSection.toLatin1(), "addr").toString(); if(strTmp == ui.addrLineEdit->text()) { bExist=true; index=i; break; } - strTmp = pConf->getItemValue(strSection.toLatin1(), "port"); + strTmp = pConf->getItemValue(strSection.toLatin1(), "port").toString(); if(ui.portLineEdit->text().toInt()!=strTmp.toInt()) { bExist=true; index=i; break; } } Modified: trunk/qterm-qt4/src/schemadialog.cpp =================================================================== --- trunk/qterm-qt4/src/schemadialog.cpp 2008-11-24 21:39:06 UTC (rev 531) +++ trunk/qterm-qt4/src/schemadialog.cpp 2008-11-24 21:39:21 UTC (rev 532) @@ -103,7 +103,7 @@ { foreach (QFileInfo fi, lstFile) { Config *pConf = new Config(fi.absoluteFilePath()); - ui.nameListWidget->addItem(pConf->getItemValue("schema","title")); + ui.nameListWidget->addItem(pConf->getItemValue("schema","title").toString()); delete pConf; fileList.append(fi.absoluteFilePath()); } @@ -116,7 +116,7 @@ { foreach (QFileInfo fi, lstFile) { Config *pConf = new Config(fi.absoluteFilePath()); - ui.nameListWidget->addItem(pConf->getItemValue("schema","title")); + ui.nameListWidget->addItem(pConf->getItemValue("schema","title").toString()); delete pConf; fileList.append(fi.absoluteFilePath()); } @@ -129,30 +129,30 @@ strCurrentSchema = strSchemaFile; - title = pConf->getItemValue("schema","title"); - pxmBg = pConf->getItemValue("image", "name"); - QString strTmp = pConf->getItemValue("image","type"); + title = pConf->getItemValue("schema","title").toString(); + pxmBg = pConf->getItemValue("image", "name").toString(); + QString strTmp = pConf->getItemValue("image","type").toString(); type = strTmp.toInt(); - fade.setNamedColor(pConf->getItemValue("image","fade")); - strTmp = pConf->getItemValue("image", "alpha"); + fade.setNamedColor(pConf->getItemValue("image","fade").toString()); + strTmp = pConf->getItemValue("image", "alpha").toString(); alpha = strTmp.toFloat(); - clr0.setNamedColor(pConf->getItemValue("color","color0")); - clr1.setNamedColor(pConf->getItemValue("color","color1")); - clr2.setNamedColor(pConf->getItemValue("color","color2")); - clr3.setNamedColor(pConf->getItemValue("color","color3")); - clr4.setNamedColor(pConf->getItemValue("color","color4")); - clr5.setNamedColor(pConf->getItemValue("color","color5")); - clr6.setNamedColor(pConf->getItemValue("color","color6")); - clr7.setNamedColor(pConf->getItemValue("color","color7")); - clr8.setNamedColor(pConf->getItemValue("color","color8")); - clr9.setNamedColor(pConf->getItemValue("color","color9")); - clr10.setNamedColor(pConf->getItemValue("color","color10")); - clr11.setNamedColor(pConf->getItemValue("color","color11")); - clr12.setNamedColor(pConf->getItemValue("color","color12")); - clr13.setNamedColor(pConf->getItemValue("color","color13")); - clr14.setNamedColor(pConf->getItemValue("color","color14")); - clr15.setNamedColor(pConf->getItemValue("color","color15")); + clr0.setNamedColor(pConf->getItemValue("color","color0").toString()); + clr1.setNamedColor(pConf->getItemValue("color","color1").toString()); + clr2.setNamedColor(pConf->getItemValue("color","color2").toString()); + clr3.setNamedColor(pConf->getItemValue("color","color3").toString()); + clr4.setNamedColor(pConf->getItemValue("color","color4").toString()); + clr5.setNamedColor(pConf->getItemValue("color","color5").toString()); + clr6.setNamedColor(pConf->getItemValue("color","color6").toString()); + clr7.setNamedColor(pConf->getItemValue("color","color7").toString()); + clr8.setNamedColor(pConf->getItemValue("color","color8").toString()); + clr9.setNamedColor(pConf->getItemValue("color","color9").toString()); + clr10.setNamedColor(pConf->getItemValue("color","color10").toString()); + clr11.setNamedColor(pConf->getItemValue("color","color11").toString()); + clr12.setNamedColor(pConf->getItemValue("color","color12").toString()); + clr13.setNamedColor(pConf->getItemValue("color","color13").toString()); + clr14.setNamedColor(pConf->getItemValue("color","color14").toString()); + clr15.setNamedColor(pConf->getItemValue("color","color15").toString()); delete pConf; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-24 22:55:56
|
Revision: 537 http://qterm.svn.sourceforge.net/qterm/?rev=537&view=rev Author: hephooey Date: 2008-11-24 21:39:53 +0000 (Mon, 24 Nov 2008) Log Message: ----------- Save/load toolbar settings. TODO: 1. How to save/load connect button which comes with a popup menu. 2. Custom key toolbar, should the setting be saved? Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:39:47 UTC (rev 536) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:39:53 UTC (rev 537) @@ -194,6 +194,7 @@ Global::instance()->saveState(saveState()); Global::instance()->saveConfig(); saveShortcuts(); + saveToolbars(); } //addressbook @@ -733,14 +734,14 @@ connectButton = new QToolButton(mdiTools); connectButton->setIcon(QPixmap(Global::instance()->pathPic() + "pic/connect.png")); - mdiTools->addWidget(connectButton); + QAction * connectAction = mdiTools->addWidget(connectButton); + connectAction->setObjectName("actionConnectButton"); connectMenu = new QMenu(this); connect(connectMenu, SIGNAL(aboutToShow()), this, SLOT(popupConnectMenu())); connectButton->setMenu(connectMenu); connectButton->setPopupMode(QToolButton::InstantPopup); - mdiTools->addAction(m_quickConnectAction); // custom define key = addToolBar("Custom Key"); key->setObjectName("customKeyToolBar"); @@ -749,30 +750,7 @@ mdiconnectTools = addToolBar("bbs operations"); mdiconnectTools->setObjectName("bbsOperationsToolBar"); - mdiconnectTools->addAction(m_disconnectAction); - mdiconnectTools->addSeparator(); - - mdiconnectTools->addAction(m_copyAction); - mdiconnectTools->addAction(m_pasteAction); - mdiconnectTools->addAction(m_rectAction); - mdiconnectTools->addAction(m_colorCopyAction); - mdiconnectTools->addSeparator(); - - mdiconnectTools->addAction(m_fontAction); - mdiconnectTools->addAction(m_colorAction); - mdiconnectTools->addAction(m_refreshAction); - mdiconnectTools->addSeparator(); - - mdiconnectTools->addAction(m_currentSessionAction); - mdiconnectTools->addSeparator(); - - mdiconnectTools->addAction(m_copyArticleAction); - mdiconnectTools->addAction(m_antiIdleAction); - mdiconnectTools->addAction(m_autoReplyAction); - mdiconnectTools->addAction(m_viewMessageAction); - mdiconnectTools->addAction(m_mouseAction); - mdiconnectTools->addAction(m_beepAction); - mdiconnectTools->addAction(m_reconnectAction); + loadToolbars(); } void Frame::initShortcuts() @@ -1405,6 +1383,58 @@ saveShortcuts(); } +void Frame::saveToolbars() +{ + Config * conf = Global::instance()->fileCfg(); + QList<QToolBar*> toolbars = findChildren<QToolBar*>(); + QToolBar * toolbar; + foreach (toolbar, toolbars) + { + QStringList listActions; + foreach(QAction* action, toolbar->actions()) + { + if (action->objectName() == "actionConnectButton") + continue; + if(action->isSeparator()) + listActions+="Separator"; + else if (action->objectName().isEmpty()==false) + listActions+=action->objectName(); + else + qDebug() << "weird object: " << action->objectName(); + } + conf->setItemValue("Toolbars", toolbar->objectName(), listActions); + } + conf->setItemValue("Toolbars", "ButtonStyle", int(toolButtonStyle())); + conf->setItemValue("Toolbars", "IconSize", iconSize()); + conf->save(); } +void Frame::loadToolbars() +{ + Config * conf = Global::instance()->fileCfg(); + QList<QToolBar*> toolbars = findChildren<QToolBar*>(); + QToolBar * toolbar; + foreach (toolbar, toolbars) + { + QStringList actions=conf->getItemValue("Toolbars", toolbar->objectName()).toStringList(); + foreach(QString action, actions) + { + QAction* act; + if (action.isEmpty()) + continue; + if(action=="Separator") + toolbar->addSeparator(); + else { + act=findChild<QAction*>(action); + if (act != 0) + toolbar->addAction(act); + } + } + } + setToolButtonStyle(Qt::ToolButtonStyle(conf->getItemValue("Toolbars", "ButtonStyle").toInt())); + setIconSize(conf->getItemValue("Toolbars", "IconSize").toSize()); +} + +} + #include <qtermframe.moc> Modified: trunk/qterm-qt4/src/qtermframe.h =================================================================== --- trunk/qterm-qt4/src/qtermframe.h 2008-11-24 21:39:47 UTC (rev 536) +++ trunk/qterm-qt4/src/qtermframe.h 2008-11-24 21:39:53 UTC (rev 537) @@ -210,6 +210,8 @@ void saveSetting(); void saveShortcuts(); void loadShortcuts(); + void saveToolbars(); + void loadToolbars(); void addMainMenu(); void addMainTool(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-26 21:27:41
|
Revision: 541 http://qterm.svn.sourceforge.net/qterm/?rev=541&view=rev Author: hephooey Date: 2008-11-26 21:27:37 +0000 (Wed, 26 Nov 2008) Log Message: ----------- Skip custom key toolbar Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/toolbardialog.cpp Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-24 21:40:16 UTC (rev 540) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-26 21:27:37 UTC (rev 541) @@ -1397,6 +1397,8 @@ foreach (toolbar, toolbars) { QStringList listActions; + if (toolbar == key) + continue; foreach(QAction* action, toolbar->actions()) { if (action->objectName() == "actionConnectButton") @@ -1423,6 +1425,8 @@ foreach (toolbar, toolbars) { QStringList actions=conf->getItemValue("Toolbars", toolbar->objectName()).toStringList(); + if (toolbar == key) + continue; foreach(QString action, actions) { QAction* act; Modified: trunk/qterm-qt4/src/toolbardialog.cpp =================================================================== --- trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-24 21:40:16 UTC (rev 540) +++ trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-26 21:27:37 UTC (rev 541) @@ -25,7 +25,8 @@ QList<QToolBar*> toolbars = parent->findChildren<QToolBar*>(); QToolBar* toolbar; foreach(toolbar, toolbars) - comboToolbars->addItem(toolbar->windowTitle(), QVariant::fromValue((QObject*)toolbar)); + if (toolbar->objectName() != "customKeyToolBar") + comboToolbars->addItem(toolbar->windowTitle(), QVariant::fromValue((QObject*)toolbar)); comboToolbarsCurrentIndexChanged(0); QMainWindow *mwParent = qobject_cast<QMainWindow*>(parent); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-26 21:28:04
|
Revision: 543 http://qterm.svn.sourceforge.net/qterm/?rev=543&view=rev Author: hephooey Date: 2008-11-26 21:28:00 +0000 (Wed, 26 Nov 2008) Log Message: ----------- Do not show actions in configure dialog if they are part of a action group. Not sure if this is a good idea Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/shortcutsdialog.cpp trunk/qterm-qt4/src/toolbardialog.cpp Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-26 21:27:47 UTC (rev 542) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-26 21:28:00 UTC (rev 543) @@ -1436,7 +1436,7 @@ toolbar->addSeparator(); else { act=findChild<QAction*>(action); - if (act != 0) + if (act != 0 && act->actionGroup()==0) toolbar->addAction(act); } } Modified: trunk/qterm-qt4/src/shortcutsdialog.cpp =================================================================== --- trunk/qterm-qt4/src/shortcutsdialog.cpp 2008-11-26 21:27:47 UTC (rev 542) +++ trunk/qterm-qt4/src/shortcutsdialog.cpp 2008-11-26 21:28:00 UTC (rev 543) @@ -20,6 +20,8 @@ foreach(QAction* action, actions) { //toolTip() gives text without '&' + if (action->actionGroup() != 0) + continue; QTableWidgetItem *itemAction = new QTableWidgetItem(action->toolTip()); QString shortcut = action->shortcut().toString(); QTableWidgetItem *itemShortcut = new QTableWidgetItem(shortcut); Modified: trunk/qterm-qt4/src/toolbardialog.cpp =================================================================== --- trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-26 21:27:47 UTC (rev 542) +++ trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-26 21:28:00 UTC (rev 543) @@ -14,6 +14,8 @@ QList<QAction*> actions = parent->findChildren<QAction*>(QRegExp("action*")); QAction* action; foreach(action, actions) { + if (action->actionGroup() != 0) + continue; QListWidgetItem* item = new QListWidgetItem(action->toolTip()); item->setIcon(action->icon()); item->setData(Qt::UserRole, QVariant::fromValue((QObject*)action)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-26 21:29:03
|
Revision: 548 http://qterm.svn.sourceforge.net/qterm/?rev=548&view=rev Author: hephooey Date: 2008-11-26 21:28:59 +0000 (Wed, 26 Nov 2008) Log Message: ----------- Support actions in KDE notification Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermframe.h trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermglobal.h trunk/qterm-qt4/src/qtermwindow.cpp Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-26 21:28:43 UTC (rev 547) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-26 21:28:59 UTC (rev 548) @@ -86,6 +86,8 @@ tray = 0; trayMenu = 0; + Global::instance()->setParent(this); + connect(Global::instance(), SIGNAL(showQTerm()), this, SLOT(slotShowQTerm())); //create a tabbar in the hbox tabBar = new QTabBar(statusBar()); @@ -1453,6 +1455,11 @@ saveToolbars(); } +void Frame::slotShowQTerm() +{ + popupFocusIn(NULL); } +} + #include <qtermframe.moc> Modified: trunk/qterm-qt4/src/qtermframe.h =================================================================== --- trunk/qterm-qt4/src/qtermframe.h 2008-11-26 21:28:43 UTC (rev 547) +++ trunk/qterm-qt4/src/qtermframe.h 2008-11-26 21:28:59 UTC (rev 548) @@ -111,6 +111,7 @@ void configShortcuts(); void configToolbars(); + void slotShowQTerm(); public: QTabBar *tabBar; WndMgr * wndmgr; Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-26 21:28:43 UTC (rev 547) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-26 21:28:59 UTC (rev 548) @@ -55,7 +55,7 @@ } Global::Global() - : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_fullScreen(false), m_language(Global::English) + : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_fullScreen(false), m_dbusAvailable(false), m_language(Global::English),m_idList() { if (!iniWorkingDir(qApp->arguments()[0])) { m_status = INIT_ERROR; @@ -67,6 +67,7 @@ m_status = INIT_ERROR; return; } + initDBus(); } bool Global::isOK() @@ -778,11 +779,69 @@ bool Global::dbusExist() const { - return QDBusConnection::sessionBus().interface()->isServiceRegistered(dbusServiceName); + return m_dbusAvailable; } -bool Global::sendDBusNotification(const QString & summary, const QString & body) +void Global::createDBusConnection() { + bool connected = QDBusConnection::sessionBus().connect(QString(), // from any service + dbusPath, + dbusInterfaceName, + "ActionInvoked", + this, + SLOT(slotDBusNotificationActionInvoked(uint,const QString&))); + if (!connected) { + qDebug() << "warning: failed to connect to NotificationClosed dbus signal"; + } + connected = QDBusConnection::sessionBus().connect(QString(), // from any service + dbusPath, + dbusInterfaceName, + "NotificationClosed", + this, + SLOT(slotDBusNotificationClosed(uint,uint))); + if (!connected) { + qDebug() << "warning: failed to connect to NotificationClosed dbus signal"; + } +} + +void Global::initDBus() +{ + m_idList.clear(); + QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface(); + m_dbusAvailable = interface && interface->isServiceRegistered(dbusServiceName); + + if( m_dbusAvailable) { + qDebug() << "using" << dbusServiceName << "for popups"; + createDBusConnection(); + } + + // to catch register/unregister events from service in runtime + connect(interface, SIGNAL(serviceOwnerChanged(const QString&, const QString&, const QString&)), this, SLOT(slotServiceOwnerChanged(const QString&, const QString&, const QString&))); +} + +void Global::slotServiceOwnerChanged( const QString & serviceName, const QString & oldOwner, const QString & newOwner ) +{ + if(serviceName == dbusServiceName) + { + if(oldOwner.isEmpty()) + { + m_idList.clear(); + m_dbusAvailable = true; + qDebug() << dbusServiceName << " was registered on bus, now using it to show popups"; + // connect to action invocation signals + createDBusConnection(); + } + if(newOwner.isEmpty()) + { + m_idList.clear(); + m_dbusAvailable = false; + qDebug() << dbusServiceName << " was unregistered from bus, using passive popups from now on"; + } + } +} + +bool Global::sendDBusNotification(const QString & summary, const QString & body, QList<Global::Action> actions) +{ QDBusMessage message = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "Notify" ); uint id = 0; QList<QVariant> args; @@ -793,13 +852,64 @@ args.append(summary); args.append(body); QStringList actionList; + foreach (Global::Action action, actions) { + if (action==Global::Show_QTerm) { + actionList.append(QString::number(Global::Show_QTerm)); + actionList.append("Show QTerm"); + } + } args.append(actionList); args.append(QVariantMap()); args.append(6*1000); message.setArguments(args); - QDBusMessage response = QDBusConnection::sessionBus().call(message); + QDBusMessage replyMsg = QDBusConnection::sessionBus().call(message); + if(replyMsg.type() == QDBusMessage::ReplyMessage) { + if (!replyMsg.arguments().isEmpty()) { + uint dbus_id = replyMsg.arguments().at(0).toUInt(); + m_idList.append(dbus_id); + } else { + qDebug() << "error: received reply with no arguments"; + } + } else if (replyMsg.type() == QDBusMessage::ErrorMessage) { + qDebug() << "error: failed to send dbus message"; + } else { + qDebug() << "unexpected reply type"; + } //TODO: handle errors return true; } +void Global::slotDBusNotificationActionInvoked(uint id, const QString action) +{ + if (m_idList.contains(id)) { + if (action.toInt() == Global::Show_QTerm) { + closeNotification(id); + emit showQTerm(); + } + } +} + +void Global::slotDBusNotificationClosed(uint id, uint reason) +{ + if (m_idList.contains(id)) + m_idList.removeAll(id); +} + +void Global::closeNotification(uint id) +{ + if (m_idList.contains(id)) { + m_idList.removeAll(id); + QDBusMessage m = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "CloseNotification" ); + QList<QVariant> args; + args.append(id); + m.setArguments( args ); + bool queued = QDBusConnection::sessionBus().send(m); + if (!queued) { + qDebug() << "warning: failed to queue dbus message"; + } + } +} + } // namespace QTerm + +#include <qtermglobal.moc> Modified: trunk/qterm-qt4/src/qtermglobal.h =================================================================== --- trunk/qterm-qt4/src/qtermglobal.h 2008-11-26 21:28:43 UTC (rev 547) +++ trunk/qterm-qt4/src/qtermglobal.h 2008-11-26 21:28:59 UTC (rev 548) @@ -38,6 +38,9 @@ INIT_OK, INIT_ERROR }; + enum Action { + Show_QTerm + }; struct Pref { Codec nXIM; int nWordWrap; @@ -100,15 +103,24 @@ void saveGeometry( const QByteArray geometry); void saveState( const QByteArray state); void cleanup(); - bool sendDBusNotification(const QString & summary, const QString & body); + bool sendDBusNotification(const QString & summary, const QString & body, QList<Global::Action> actions); +signals: + void showQTerm(); +private slots: + void slotServiceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner); + void slotDBusNotificationActionInvoked(uint id, const QString action); + void slotDBusNotificationClosed(uint id, uint reason); private: Global(); static Global* m_Instance; bool iniWorkingDir(QString param); bool iniSettings(); + void initDBus(); + void createDBusConnection(); bool isPathExist(const QString & path); bool createLocalFile(const QString & dst, const QString & src); + void closeNotification(uint id); QString m_fileCfg; QString m_addrCfg; QString m_pathLib; @@ -126,7 +138,9 @@ Position m_scrollPos; bool m_fullScreen; bool m_switchBar; + bool m_dbusAvailable; Language m_language; + QList<uint> m_idList; }; } // namespace QTerm Modified: trunk/qterm-qt4/src/qtermwindow.cpp =================================================================== --- trunk/qterm-qt4/src/qtermwindow.cpp 2008-11-26 21:28:43 UTC (rev 547) +++ trunk/qterm-qt4/src/qtermwindow.cpp 2008-11-26 21:28:59 UTC (rev 548) @@ -1065,7 +1065,9 @@ if(!isActiveWindow() || m_pFrame->wndmgr->activeWindow()!=this) { if (Global::instance()->dbusExist()) { - Global::instance()->sendDBusNotification("New Message in QTerm", fromBBSCodec(strMsg.toLatin1())); + QList<Global::Action> actions; + actions.append(Global::Show_QTerm); + Global::instance()->sendDBusNotification("New Message in QTerm", fromBBSCodec(strMsg.toLatin1()),actions); } else { m_popWin->setText(fromBBSCodec(strMsg.toLatin1())); m_popWin->popup(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-27 05:54:33
|
Revision: 550 http://qterm.svn.sourceforge.net/qterm/?rev=550&view=rev Author: hephooey Date: 2008-11-27 05:54:28 +0000 (Thu, 27 Nov 2008) Log Message: ----------- New hasItem function Modified Paths: -------------- trunk/qterm-qt4/src/qtermconfig.cpp trunk/qterm-qt4/src/qtermconfig.h Modified: trunk/qterm-qt4/src/qtermconfig.cpp =================================================================== --- trunk/qterm-qt4/src/qtermconfig.cpp 2008-11-26 21:29:05 UTC (rev 549) +++ trunk/qterm-qt4/src/qtermconfig.cpp 2008-11-27 05:54:28 UTC (rev 550) @@ -96,6 +96,12 @@ return section.contains(szSection); } +bool Config::hasItem(const QString & szSection, const QString & szItemName) +{ + QString key = szSection+"/"+szItemName; + return m_settings->contains(key); +} + bool Config::setItemValue(const QString & szSection, const QString & szItemName, const QVariant & szItemValue) { Modified: trunk/qterm-qt4/src/qtermconfig.h =================================================================== --- trunk/qterm-qt4/src/qtermconfig.h 2008-11-26 21:29:05 UTC (rev 549) +++ trunk/qterm-qt4/src/qtermconfig.h 2008-11-27 05:54:28 UTC (rev 550) @@ -25,6 +25,7 @@ bool renameSection(const QString & szSection, const QString & szNewName); bool hasSection(const QString & szSection); + bool hasItem(const QString & szSection, const QString & szItemName); private: bool checkError(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-27 05:54:38
|
Revision: 551 http://qterm.svn.sourceforge.net/qterm/?rev=551&view=rev Author: hephooey Date: 2008-11-27 05:54:33 +0000 (Thu, 27 Nov 2008) Log Message: ----------- New code to remember position of the toolbars, not very happy with it since it is pretty messed up by the "automatically showing bbs operation toolbar when new window is created" function. Maybe I will just remove it in the next version. Also there is no way except modify the config file to recover the toolbars if you hide them all. There should be a menu item to show them, pending for the next version. Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermglobal.h Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-27 05:54:28 UTC (rev 550) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-27 05:54:33 UTC (rev 551) @@ -148,6 +148,9 @@ m_fullAction->setChecked(true); showFullScreen(); } + mdiTools->setVisible(Global::instance()->showToolBar(mdiTools->objectName())); + mdiconnectTools->setVisible(Global::instance()->showToolBar(mdiconnectTools->objectName())); + key->setVisible(Global::instance()->showToolBar(key->objectName())); QStyle * style = QStyleFactory::create(Global::instance()->style()); if (style) @@ -1185,10 +1188,14 @@ m_scriptRunAction->setEnabled(enable); m_scriptStopAction->setEnabled(enable); - if (enable) - mdiconnectTools->show(); - else + if (enable) { + mdiconnectTools->setVisible(Global::instance()->showToolBar(mdiconnectTools->objectName())); + } else { + Global::instance()->setShowToolBar(mdiTools->objectName(), !mdiTools->isHidden()); + Global::instance()->setShowToolBar(mdiconnectTools->objectName(),!mdiconnectTools->isHidden()); + Global::instance()->setShowToolBar(key->objectName(),!key->isHidden()); mdiconnectTools->hide(); + } return; } Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-27 05:54:28 UTC (rev 550) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-11-27 05:54:33 UTC (rev 551) @@ -55,7 +55,7 @@ } Global::Global() - : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_fullScreen(false), m_dbusAvailable(false), m_language(Global::English),m_idList() + : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_fullScreen(false), m_dbusAvailable(false), m_language(Global::English),m_idList(), m_showToolBar() { if (!iniWorkingDir(qApp->arguments()[0])) { m_status = INIT_ERROR; @@ -715,6 +715,37 @@ } +bool Global::showToolBar(const QString & toolbar) +{ + if (m_showToolBar.contains(toolbar)) { + return m_showToolBar.value(toolbar); + } else { + if (m_config->hasItem("ToolBars", toolbar+"Shown")) { + bool isShown = m_config->getItemValue("ToolBars", toolbar+"Shown").toBool(); + m_showToolBar.insert(toolbar, isShown); + return isShown; + } else { + // Show toolbar by default + m_showToolBar.insert(toolbar, true); + return true; + } + } +} + +void Global::setShowToolBar(const QString & toolbar, bool isShown) +{ + m_showToolBar.insert(toolbar, isShown); +} + +void Global::saveShowToolBar() +{ + QMapIterator<QString, bool> i(m_showToolBar); + while (i.hasNext()) { + i.next(); + m_config->setItemValue("ToolBars",i.key()+"Shown", i.value()); + } +} + void Global::saveConfig() { @@ -744,6 +775,7 @@ m_config->setItemValue("global", "statusbar", showStatusBar() ? "1" : "0"); m_config->setItemValue("global", "switchbar", showSwitchBar() ? "1" : "0"); + saveShowToolBar(); m_config->save(); } Modified: trunk/qterm-qt4/src/qtermglobal.h =================================================================== --- trunk/qterm-qt4/src/qtermglobal.h 2008-11-27 05:54:28 UTC (rev 550) +++ trunk/qterm-qt4/src/qtermglobal.h 2008-11-27 05:54:33 UTC (rev 551) @@ -16,6 +16,7 @@ #include <QtCore/QMutex> #include <QtCore/QString> +#include <QtCore/QMap> #include <QtCore/QObject> namespace QTerm @@ -84,6 +85,7 @@ Position scrollPosition() const; bool isFullScreen() const; bool showSwitchBar() const; + bool showToolBar(const QString & toolbar); bool dbusExist() const; const QString & style() const; @@ -96,6 +98,8 @@ void setSwitchBar(bool isShow); void setLanguage(const Language language); void setStyle(const QString & style); + void setShowToolBar(const QString & toolbar, bool isShown); + void saveShowToolBar(); void loadConfig(); //TODO: Merge with iniSettings void saveConfig(); QByteArray loadGeometry(); @@ -141,6 +145,7 @@ bool m_dbusAvailable; Language m_language; QList<uint> m_idList; + QMap<QString, bool> m_showToolBar; }; } // namespace QTerm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-27 22:22:27
|
Revision: 558 http://qterm.svn.sourceforge.net/qterm/?rev=558&view=rev Author: hephooey Date: 2008-11-27 21:51:09 +0000 (Thu, 27 Nov 2008) Log Message: ----------- Default button to restore the default behavior of toolbars Modified Paths: -------------- trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/toolbardialog.cpp trunk/qterm-qt4/src/toolbardialog.h trunk/qterm-qt4/src/ui/toolbardialog.ui Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-11-27 21:50:21 UTC (rev 557) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-11-27 21:51:09 UTC (rev 558) @@ -737,7 +737,8 @@ mdiTools = addToolBar("Main ToolBar"); mdiTools->setObjectName("mainToolBar"); - connectButton = new QToolButton(mdiTools); + connectButton = new QToolButton(this); + connectButton->setObjectName("buttonConnect"); connectButton->setIcon(QPixmap(Global::instance()->pathPic() + "pic/connect.png")); QAction * connectAction = mdiTools->addWidget(connectButton); Modified: trunk/qterm-qt4/src/toolbardialog.cpp =================================================================== --- trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-27 21:50:21 UTC (rev 557) +++ trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-27 21:51:09 UTC (rev 558) @@ -4,12 +4,14 @@ #include <QtCore/QRegExp> #include <QtCore/QSettings> #include <QtGui/QMainWindow> +#include <QtGui/QToolButton> ToolbarDialog::ToolbarDialog(QWidget* parent) - : QDialog(parent) + : QDialog(parent),m_defaultToolBars() { setupUi(this); + createDefaultToolBars(); // populate all available actions QList<QAction*> actions = parent->findChildren<QAction*>(QRegExp("action*")); QAction* action; @@ -45,7 +47,7 @@ connect(comboToolbars, SIGNAL(currentIndexChanged(int)), this, SLOT(comboToolbarsCurrentIndexChanged(int))); connect(comboIconSize, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(comboIconSizeCurrentIndexChanged(const QString &))); connect(comboButtonStyle, SIGNAL(currentIndexChanged(int)),this, SLOT(comboButtonStyleCurrentIndexChanged(int))); - + connect(buttonDefault, SIGNAL(clicked()), this, SLOT(restoreDefaultToolbars())); } ToolbarDialog::~ToolbarDialog() @@ -183,7 +185,10 @@ QToolBar *toolbar = qobject_cast<QToolBar*>(comboToolbars->itemData(index).value<QObject*>()); foreach(QAction *action, toolbar->actions()) { QListWidgetItem* item = new QListWidgetItem(); - if (action->isSeparator()) + // another ugly hack for connectButton + if (action->objectName() == "actionConnectButton") + continue; + else if (action->isSeparator()) item->setText("Separator"); else { item->setText(action->toolTip()); @@ -195,4 +200,40 @@ } } +void ToolbarDialog::createDefaultToolBars() +{ + QStringList listActions; + listActions << "actionQuickConnect"; + m_defaultToolBars.insert("mainToolBar", listActions); + + listActions.clear(); + listActions << "actionDisconnect" << "Separator" << "actionCopy" << "actionPaste" << "actionRect" << "actionColorCopy" << "Separator" << "actionFont" << "actionColor" << "actionRefresh" << "Separator" << "actionCurrentSession" << "Separator" << "actionCopyArticle" << "actionAntiIdle" << "actionAutoReply" << "actionViewMessage" << "actionMouse" << "actionBeep" << "actionReconnect"; + m_defaultToolBars.insert("bbsOperationsToolBar", listActions); +} + +void ToolbarDialog::restoreDefaultToolbars() +{ + QList<QToolBar*> toolbars = parent()->findChildren<QToolBar*>(); + QToolBar* toolbar; + // populate all available actions + foreach(toolbar, toolbars) { + if (m_defaultToolBars.contains(toolbar->objectName())){ + QList<QAction *> actions = toolbar->actions(); + QStringList listActions = m_defaultToolBars.value(toolbar->objectName()); + // Ugly hack for connectButton + foreach (QAction * act, actions) { + if (toolbar->objectName() != "mainToolBar" && act->objectName() != "actionConnectButton") + toolbar->removeAction(act); + } + foreach (QString action, listActions) { + QAction * obj = parent()->findChild<QAction*>(action); + if (obj != NULL) { + toolbar->addAction(obj); + } + } + } + } + comboToolbarsCurrentIndexChanged(comboToolbars->currentIndex()); +} + #include <toolbardialog.moc> Modified: trunk/qterm-qt4/src/toolbardialog.h =================================================================== --- trunk/qterm-qt4/src/toolbardialog.h 2008-11-27 21:50:21 UTC (rev 557) +++ trunk/qterm-qt4/src/toolbardialog.h 2008-11-27 21:51:09 UTC (rev 558) @@ -20,6 +20,10 @@ void comboToolbarsCurrentIndexChanged(int); void comboIconSizeCurrentIndexChanged(const QString&); void comboButtonStyleCurrentIndexChanged(int); + void restoreDefaultToolbars(); +private: + void createDefaultToolBars(); + QMap<QString, QStringList> m_defaultToolBars; }; #endif //TOOLBARDIALOG_H Modified: trunk/qterm-qt4/src/ui/toolbardialog.ui =================================================================== --- trunk/qterm-qt4/src/ui/toolbardialog.ui 2008-11-27 21:50:21 UTC (rev 557) +++ trunk/qterm-qt4/src/ui/toolbardialog.ui 2008-11-27 21:51:09 UTC (rev 558) @@ -5,292 +5,366 @@ <rect> <x>0</x> <y>0</y> - <width>668</width> - <height>479</height> + <width>796</width> + <height>600</height> </rect> </property> + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize" > + <size> + <width>796</width> + <height>600</height> + </size> + </property> + <property name="maximumSize" > + <size> + <width>796</width> + <height>600</height> + </size> + </property> <property name="windowTitle" > <string>Configure Toolbars</string> </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> + <widget class="QPushButton" name="buttonDone" > + <property name="geometry" > + <rect> + <x>570</x> + <y>550</y> + <width>100</width> + <height>31</height> + </rect> </property> - <property name="spacing" > - <number>6</number> + <property name="text" > + <string>OK</string> </property> - <item row="2" column="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>20</width> - <height>91</height> - </size> - </property> - </spacer> + </widget> + <widget class="QComboBox" name="comboButtonStyle" > + <property name="geometry" > + <rect> + <x>120</x> + <y>440</y> + <width>661</width> + <height>31</height> + </rect> + </property> + <item> + <property name="text" > + <string>Icon Only</string> + </property> </item> - <item row="0" column="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>20</width> - <height>111</height> - </size> - </property> - </spacer> + <item> + <property name="text" > + <string>Text Only</string> + </property> </item> - <item row="1" column="2" colspan="2" > - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QPushButton" name="buttonUp" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize" > - <size> - <width>30</width> - <height>30</height> - </size> - </property> - <property name="text" > - <string>^</string> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QPushButton" name="buttonDown" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize" > - <size> - <width>30</width> - <height>30</height> - </size> - </property> - <property name="baseSize" > - <size> - <width>77</width> - <height>27</height> - </size> - </property> - <property name="text" > - <string>V</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QPushButton" name="buttonRemove" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize" > - <size> - <width>30</width> - <height>30</height> - </size> - </property> - <property name="text" > - <string><</string> - </property> - </widget> - </item> - <item row="1" column="2" > - <widget class="QPushButton" name="buttonAdd" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize" > - <size> - <width>30</width> - <height>30</height> - </size> - </property> - <property name="baseSize" > - <size> - <width>41</width> - <height>27</height> - </size> - </property> - <property name="text" > - <string>></string> - </property> - </widget> - </item> - </layout> + <item> + <property name="text" > + <string>Text beside Icon</string> + </property> </item> - <item row="6" column="0" colspan="5" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>361</width> - <height>20</height> - </size> - </property> - </spacer> + <item> + <property name="text" > + <string>Text below Icon</string> + </property> </item> - <item row="6" column="5" > - <widget class="QPushButton" name="buttonDone" > - <property name="text" > - <string>Done</string> - </property> - </widget> + </widget> + <widget class="QComboBox" name="comboIconSize" > + <property name="geometry" > + <rect> + <x>120</x> + <y>480</y> + <width>661</width> + <height>31</height> + </rect> + </property> + <item> + <property name="text" > + <string>16x16</string> + </property> </item> - <item row="4" column="3" colspan="3" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>131</width> - <height>21</height> - </size> - </property> - </spacer> + <item> + <property name="text" > + <string>32x32</string> + </property> </item> - <item row="3" column="3" colspan="3" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>131</width> - <height>21</height> - </size> - </property> - </spacer> + <item> + <property name="text" > + <string>48x48</string> + </property> </item> - <item rowspan="3" row="0" column="0" colspan="2" > - <layout class="QVBoxLayout" > - <property name="spacing" > - <number>6</number> - </property> - <property name="margin" > - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_2" > - <property name="text" > - <string>Available Actions</string> - </property> - </widget> - </item> - <item> - <widget class="QListWidget" name="listAllActions" /> - </item> - </layout> - </item> - <item row="3" column="1" colspan="2" > - <widget class="QComboBox" name="comboButtonStyle" > - <item> - <property name="text" > - <string>Icon Only</string> - </property> - </item> - <item> - <property name="text" > - <string>Text Only</string> - </property> - </item> - <item> - <property name="text" > - <string>Text beside Icon</string> - </property> - </item> - <item> - <property name="text" > - <string>Text below Icon</string> - </property> - </item> - </widget> - </item> - <item row="4" column="1" colspan="2" > - <widget class="QComboBox" name="comboIconSize" > - <item> - <property name="text" > - <string>16x16</string> - </property> - </item> - <item> - <property name="text" > - <string>32x32</string> - </property> - </item> - <item> - <property name="text" > - <string>48x48</string> - </property> - </item> - </widget> - </item> - <item row="5" column="0" colspan="6" > - <widget class="Line" name="line" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Show</string> - </property> - </widget> - </item> - <item row="4" column="0" > - <widget class="QLabel" name="label_3" > - <property name="text" > - <string>Icon Size</string> - </property> - </widget> - </item> - <item rowspan="3" row="0" column="4" colspan="2" > - <layout class="QVBoxLayout" > - <property name="spacing" > - <number>6</number> - </property> - <property name="margin" > - <number>0</number> - </property> - <item> - <widget class="QComboBox" name="comboToolbars" /> - </item> - <item> - <widget class="QListWidget" name="listUsedActions" /> - </item> - </layout> - </item> - </layout> + </widget> + <widget class="QLabel" name="label" > + <property name="geometry" > + <rect> + <x>10</x> + <y>440</y> + <width>100</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Text Position:</string> + </property> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="label_3" > + <property name="geometry" > + <rect> + <x>10</x> + <y>480</y> + <width>100</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Icon Size:</string> + </property> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + <widget class="QLabel" name="label_4" > + <property name="geometry" > + <rect> + <x>480</x> + <y>80</y> + <width>122</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Current Actions:</string> + </property> + </widget> + <widget class="QLabel" name="label_5" > + <property name="geometry" > + <rect> + <x>10</x> + <y>10</y> + <width>58</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>ToolBar:</string> + </property> + </widget> + <widget class="QPushButton" name="buttonCancel" > + <property name="geometry" > + <rect> + <x>680</x> + <y>550</y> + <width>100</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Cancel</string> + </property> + </widget> + <widget class="QPushButton" name="buttonDefault" > + <property name="geometry" > + <rect> + <x>10</x> + <y>550</y> + <width>100</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Default</string> + </property> + </widget> + <widget class="Line" name="line" > + <property name="geometry" > + <rect> + <x>0</x> + <y>520</y> + <width>791</width> + <height>20</height> + </rect> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QPushButton" name="buttonRemove" > + <property name="geometry" > + <rect> + <x>339</x> + <y>275</y> + <width>30</width> + <height>29</height> + </rect> + </property> + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="text" > + <string><</string> + </property> + </widget> + <widget class="QPushButton" name="buttonUp" > + <property name="geometry" > + <rect> + <x>380</x> + <y>240</y> + <width>30</width> + <height>29</height> + </rect> + </property> + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="text" > + <string>^</string> + </property> + </widget> + <widget class="QPushButton" name="buttonDown" > + <property name="geometry" > + <rect> + <x>380</x> + <y>310</y> + <width>30</width> + <height>29</height> + </rect> + </property> + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="baseSize" > + <size> + <width>77</width> + <height>27</height> + </size> + </property> + <property name="text" > + <string>V</string> + </property> + </widget> + <widget class="QPushButton" name="buttonAdd" > + <property name="geometry" > + <rect> + <x>421</x> + <y>275</y> + <width>30</width> + <height>29</height> + </rect> + </property> + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="baseSize" > + <size> + <width>41</width> + <height>27</height> + </size> + </property> + <property name="text" > + <string>></string> + </property> + </widget> + <widget class="QComboBox" name="comboToolbars" > + <property name="geometry" > + <rect> + <x>10</x> + <y>40</y> + <width>771</width> + <height>32</height> + </rect> + </property> + </widget> + <widget class="QListWidget" name="listUsedActions" > + <property name="geometry" > + <rect> + <x>480</x> + <y>120</y> + <width>301</width> + <height>301</height> + </rect> + </property> + </widget> + <widget class="QLabel" name="label_2" > + <property name="geometry" > + <rect> + <x>10</x> + <y>80</y> + <width>132</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Available Actions:</string> + </property> + </widget> + <widget class="QListWidget" name="listAllActions" > + <property name="geometry" > + <rect> + <x>10</x> + <y>119</y> + <width>311</width> + <height>301</height> + </rect> + </property> + </widget> </widget> + <tabstops> + <tabstop>comboToolbars</tabstop> + <tabstop>listAllActions</tabstop> + <tabstop>listUsedActions</tabstop> + <tabstop>buttonRemove</tabstop> + <tabstop>buttonAdd</tabstop> + <tabstop>buttonUp</tabstop> + <tabstop>buttonDown</tabstop> + <tabstop>comboButtonStyle</tabstop> + <tabstop>comboIconSize</tabstop> + <tabstop>buttonDone</tabstop> + <tabstop>buttonCancel</tabstop> + <tabstop>buttonDefault</tabstop> + </tabstops> <resources/> <connections> <connection> @@ -309,5 +383,21 @@ </hint> </hints> </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>ToolbarDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>742</x> + <y>562</y> + </hint> + <hint type="destinationlabel" > + <x>309</x> + <y>555</y> + </hint> + </hints> + </connection> </connections> </ui> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-27 22:22:35
|
Revision: 556 http://qterm.svn.sourceforge.net/qterm/?rev=556&view=rev Author: hephooey Date: 2008-11-27 21:49:49 +0000 (Thu, 27 Nov 2008) Log Message: ----------- Cosmetic change about include Modified Paths: -------------- trunk/qterm-qt4/src/shortcutsdialog.cpp trunk/qterm-qt4/src/shortcutsdialog.h trunk/qterm-qt4/src/toolbardialog.cpp Modified: trunk/qterm-qt4/src/shortcutsdialog.cpp =================================================================== --- trunk/qterm-qt4/src/shortcutsdialog.cpp 2008-11-27 21:49:03 UTC (rev 555) +++ trunk/qterm-qt4/src/shortcutsdialog.cpp 2008-11-27 21:49:49 UTC (rev 556) @@ -1,8 +1,8 @@ #include "shortcutsdialog.h" -#include <QKeyEvent> -#include <QMessageBox> -#include <QShortcut> +#include <QtGui/QKeyEvent> +#include <QtGui/QMessageBox> +#include <QtGui/QShortcut> namespace QTerm { Modified: trunk/qterm-qt4/src/shortcutsdialog.h =================================================================== --- trunk/qterm-qt4/src/shortcutsdialog.h 2008-11-27 21:49:03 UTC (rev 555) +++ trunk/qterm-qt4/src/shortcutsdialog.h 2008-11-27 21:49:49 UTC (rev 556) @@ -2,7 +2,7 @@ #define SHORTCUTSDIALOG_H #include "ui_shortcutsdialog.h" -#include <QShortcut> +#include <QtGui/QShortcut> namespace QTerm{ Modified: trunk/qterm-qt4/src/toolbardialog.cpp =================================================================== --- trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-27 21:49:03 UTC (rev 555) +++ trunk/qterm-qt4/src/toolbardialog.cpp 2008-11-27 21:49:49 UTC (rev 556) @@ -1,9 +1,9 @@ #include "toolbardialog.h" -#include <QToolBar> -#include <QRegExp> -#include <QSettings> -#include <QMainWindow> +#include <QtGui/QToolBar> +#include <QtCore/QRegExp> +#include <QtCore/QSettings> +#include <QtGui/QMainWindow> ToolbarDialog::ToolbarDialog(QWidget* parent) : QDialog(parent) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-27 22:22:43
|
Revision: 557 http://qterm.svn.sourceforge.net/qterm/?rev=557&view=rev Author: hephooey Date: 2008-11-27 21:50:21 +0000 (Thu, 27 Nov 2008) Log Message: ----------- Add a default button to restore the default shortcuts. Also simplify the code a little bit. Modified Paths: -------------- trunk/qterm-qt4/src/shortcutsdialog.cpp trunk/qterm-qt4/src/shortcutsdialog.h trunk/qterm-qt4/src/ui/shortcutsdialog.ui Modified: trunk/qterm-qt4/src/shortcutsdialog.cpp =================================================================== --- trunk/qterm-qt4/src/shortcutsdialog.cpp 2008-11-27 21:49:49 UTC (rev 556) +++ trunk/qterm-qt4/src/shortcutsdialog.cpp 2008-11-27 21:50:21 UTC (rev 557) @@ -7,7 +7,7 @@ namespace QTerm { ShortcutsDialog::ShortcutsDialog(QWidget* parent, QList<QAction*> actions, QList<QShortcut*> shortcuts) - :QDialog(parent) + :QDialog(parent),m_defaultShortcut() { setupUi(this); editShortcut->installEventFilter(this); @@ -15,9 +15,11 @@ connect(buttonAssign, SIGNAL(clicked()), this, SLOT(buttonAssignClicked())); connect(buttonRemove, SIGNAL(clicked()), this, SLOT(buttonRemoveClicked())); connect(buttonDone, SIGNAL(clicked()), this, SLOT(buttonDoneClicked())); + connect(buttonDefault, SIGNAL(clicked()), this, SLOT(restoreDefaultShortcut())); connect(editShortcut, SIGNAL(textChanged(const QString &)), this, SLOT(editShortcutTextChanged(const QString &))); connect(tableWidget, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(tableWidgetCurrentCellChanged(int,int,int,int))); + createDefaultShortcut(); foreach(QAction* action, actions) { //toolTip() gives text without '&' if (action->actionGroup() != 0) @@ -47,10 +49,24 @@ tableWidget->setCurrentCell(0, 0); } +void ShortcutsDialog::createDefaultShortcut() +{ + m_defaultShortcut.insert("actionAbout","F1"); + m_defaultShortcut.insert("actionAddress","F2"); + m_defaultShortcut.insert("actionQuickConnect","F3"); + m_defaultShortcut.insert("actionRefresh","F5"); + m_defaultShortcut.insert("actionFull","F6"); + m_defaultShortcut.insert("actionScriptRun","F7"); + m_defaultShortcut.insert("actionScriptStop","F8"); + m_defaultShortcut.insert("actionCopyArticle","F9"); + m_defaultShortcut.insert("actionViewMessage","F10"); + m_defaultShortcut.insert("actionBoss","F12"); + m_defaultShortcut.insert("actionCopy","Ctrl+Ins"); + m_defaultShortcut.insert("actionPaste","Shift+Ins"); +} + void ShortcutsDialog::buttonAssignClicked() { - QTableWidgetItem* item; - int row = listKeys.indexOf(editShortcut->text()); if (row == tableWidget->currentRow()) @@ -69,28 +85,16 @@ if (aw == QMessageBox::No) return; // clear it - item = tableWidget->item(row, 1); - item->setText(""); - listKeys.replace(row, ""); setKeySequence(obj, QKeySequence()); } // set it to the target action row = tableWidget->currentRow(); - item = tableWidget->item(row, 1); - item->setText(editShortcut->text()); - listKeys.replace(row, editShortcut->text()); setKeySequence(listActions.at(row), editShortcut->text()); } void ShortcutsDialog::buttonRemoveClicked() { int row = tableWidget->currentRow(); - // update table - QTableWidgetItem* item = tableWidget->item(row, 1); - item->setText(""); - // update listKeys - listKeys.replace(row, ""); - // update action setKeySequence(listActions.at(row), QKeySequence()); } @@ -102,10 +106,33 @@ void ShortcutsDialog::buttonDoneClicked() { } + +void ShortcutsDialog::restoreDefaultShortcut() +{ + foreach(QObject * action, listActions) { + if (m_defaultShortcut.contains(action->objectName())) { + setKeySequence(action, QKeySequence(m_defaultShortcut.value(action->objectName()))); + } else { + setKeySequence(action, QKeySequence()); + } + } + editShortcut->setText(listKeys.at(tableWidget->currentRow())); +} + +void ShortcutsDialog::updateTableItem(QObject * action, QString key) +{ + QTableWidgetItem* item; + int row = listActions.indexOf(action); + item = tableWidget->item(row, 1); + item->setText(key); + listKeys.replace(row, key); +} + void ShortcutsDialog::tableWidgetCurrentCellChanged(int row, int col, int, int) { QTableWidgetItem *item = tableWidget->item(row, 1); buttonRemove->setEnabled(!item->text().isEmpty()); + editShortcut->setText(item->text()); } bool ShortcutsDialog::eventFilter(QObject *object, QEvent *event) { @@ -155,6 +182,7 @@ QShortcut* shortcut = qobject_cast<QShortcut*>(obj); shortcut->setKey(key); } + updateTableItem(obj, key.toString()); } } Modified: trunk/qterm-qt4/src/shortcutsdialog.h =================================================================== --- trunk/qterm-qt4/src/shortcutsdialog.h 2008-11-27 21:49:49 UTC (rev 556) +++ trunk/qterm-qt4/src/shortcutsdialog.h 2008-11-27 21:50:21 UTC (rev 557) @@ -19,14 +19,18 @@ void buttonAssignClicked(); void editShortcutTextChanged(const QString&); void tableWidgetCurrentCellChanged(int, int, int, int); + void restoreDefaultShortcut(); protected: bool eventFilter(QObject *obj, QEvent *event); QString getName(QObject*); void setKeySequence(QObject*, QKeySequence); private: + void createDefaultShortcut(); + void updateTableItem(QObject * action, QString key); QList<QObject*> listActions; QList<QString> listKeys; + QMap<QString, QString> m_defaultShortcut; }; } Modified: trunk/qterm-qt4/src/ui/shortcutsdialog.ui =================================================================== --- trunk/qterm-qt4/src/ui/shortcutsdialog.ui 2008-11-27 21:49:49 UTC (rev 556) +++ trunk/qterm-qt4/src/ui/shortcutsdialog.ui 2008-11-27 21:50:21 UTC (rev 557) @@ -5,10 +5,28 @@ <rect> <x>0</x> <y>0</y> - <width>588</width> - <height>447</height> + <width>631</width> + <height>515</height> </rect> </property> + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize" > + <size> + <width>631</width> + <height>515</height> + </size> + </property> + <property name="maximumSize" > + <size> + <width>631</width> + <height>515</height> + </size> + </property> <property name="focusPolicy" > <enum>Qt::ClickFocus</enum> </property> @@ -18,129 +36,166 @@ <property name="windowTitle" > <string>Shortcuts Dialog</string> </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> + <widget class="Line" name="line" > + <property name="geometry" > + <rect> + <x>0</x> + <y>440</y> + <width>631</width> + <height>20</height> + </rect> </property> - <property name="spacing" > - <number>6</number> + <property name="orientation" > + <enum>Qt::Horizontal</enum> </property> - <item row="2" column="0" colspan="2" > - <widget class="Line" name="line" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2" > - <widget class="QTableWidget" name="tableWidget" > - <property name="editTriggers" > - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <property name="selectionBehavior" > - <enum>QAbstractItemView::SelectRows</enum> - </property> - <property name="columnCount" > - <number>2</number> - </property> - <column> - <property name="text" > - <string>Actions</string> - </property> - </column> - <column> - <property name="text" > - <string>Shortcuts</string> - </property> - </column> - </widget> - </item> - <item row="1" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>61</width> - <height>23</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0" > - <widget class="QSplitter" name="splitter" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <widget class="QLabel" name="label" > - <property name="text" > - <string>Press any key here</string> - </property> - </widget> - <widget class="QLineEdit" name="editShortcut" /> - </widget> - </item> - <item row="3" column="0" colspan="2" > - <layout class="QHBoxLayout" > - <property name="spacing" > - <number>6</number> - </property> - <property name="margin" > - <number>0</number> - </property> - <item> - <widget class="QPushButton" name="buttonAssign" > - <property name="text" > - <string>Assign</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="buttonRemove" > - <property name="text" > - <string>Remove</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>181</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="buttonDone" > - <property name="text" > - <string>Done</string> - </property> - <property name="default" > - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - </layout> + </widget> + <widget class="QTableWidget" name="tableWidget" > + <property name="geometry" > + <rect> + <x>9</x> + <y>9</y> + <width>611</width> + <height>356</height> + </rect> + </property> + <property name="editTriggers" > + <set>QAbstractItemView::NoEditTriggers</set> + </property> + <property name="selectionBehavior" > + <enum>QAbstractItemView::SelectRows</enum> + </property> + <property name="columnCount" > + <number>2</number> + </property> + <column> + <property name="text" > + <string>Actions</string> + </property> + </column> + <column> + <property name="text" > + <string>Shortcuts</string> + </property> + </column> + </widget> + <widget class="QPushButton" name="buttonCancel" > + <property name="geometry" > + <rect> + <x>530</x> + <y>470</y> + <width>91</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Cancel</string> + </property> + </widget> + <widget class="QPushButton" name="buttonDefault" > + <property name="geometry" > + <rect> + <x>10</x> + <y>470</y> + <width>120</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Default</string> + </property> + </widget> + <widget class="QPushButton" name="buttonDone" > + <property name="geometry" > + <rect> + <x>430</x> + <y>470</y> + <width>91</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>OK</string> + </property> + <property name="default" > + <bool>true</bool> + </property> + </widget> + <widget class="QLabel" name="label" > + <property name="geometry" > + <rect> + <x>11</x> + <y>390</y> + <width>148</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Press any key here:</string> + </property> + <property name="alignment" > + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="buddy" > + <cstring>editShortcut</cstring> + </property> + </widget> + <widget class="QLineEdit" name="editShortcut" > + <property name="geometry" > + <rect> + <x>163</x> + <y>390</y> + <width>261</width> + <height>32</height> + </rect> + </property> + </widget> + <widget class="QPushButton" name="buttonAssign" > + <property name="geometry" > + <rect> + <x>430</x> + <y>390</y> + <width>92</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Assign</string> + </property> + </widget> + <widget class="QPushButton" name="buttonRemove" > + <property name="geometry" > + <rect> + <x>530</x> + <y>390</y> + <width>92</width> + <height>31</height> + </rect> + </property> + <property name="text" > + <string>Remove</string> + </property> + </widget> </widget> + <tabstops> + <tabstop>editShortcut</tabstop> + <tabstop>buttonAssign</tabstop> + <tabstop>buttonRemove</tabstop> + <tabstop>buttonDone</tabstop> + <tabstop>buttonCancel</tabstop> + <tabstop>buttonDefault</tabstop> + <tabstop>tableWidget</tabstop> + </tabstops> <resources/> <connections> <connection> <sender>buttonDone</sender> <signal>clicked()</signal> <receiver>ShortcutsDialog</receiver> - <slot>reject()</slot> + <slot>accept()</slot> <hints> <hint type="sourcelabel" > - <x>369</x> - <y>253</y> + <x>520</x> + <y>500</y> </hint> <hint type="destinationlabel" > <x>179</x> @@ -148,5 +203,21 @@ </hint> </hints> </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>ShortcutsDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>585</x> + <y>473</y> + </hint> + <hint type="destinationlabel" > + <x>88</x> + <y>423</y> + </hint> + </hints> + </connection> </connections> </ui> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-27 22:22:47
|
Revision: 555 http://qterm.svn.sourceforge.net/qterm/?rev=555&view=rev Author: hephooey Date: 2008-11-27 21:49:03 +0000 (Thu, 27 Nov 2008) Log Message: ----------- Connect socket error signal Modified Paths: -------------- trunk/qterm-qt4/src/qtermsocket.cpp trunk/qterm-qt4/src/qtermsocket.h trunk/qterm-qt4/src/qtermtelnet.cpp trunk/qterm-qt4/src/qtermtelnet.h trunk/qterm-qt4/src/ssh/socket.cpp Modified: trunk/qterm-qt4/src/qtermsocket.cpp =================================================================== --- trunk/qterm-qt4/src/qtermsocket.cpp 2008-11-27 21:48:13 UTC (rev 554) +++ trunk/qterm-qt4/src/qtermsocket.cpp 2008-11-27 21:49:03 UTC (rev 555) @@ -54,7 +54,7 @@ connect(m_socket, SIGNAL(connectionClosed()), this, SIGNAL(connectionClosed())); connect(m_socket, SIGNAL(delayedCloseFinished()), this, SIGNAL(delayedCloseFinished())); connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); - connect(m_socket, SIGNAL(error(int)), this, SIGNAL(error(int))); + connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError))); } SocketPrivate::~SocketPrivate() @@ -556,7 +556,7 @@ connect(d_socket, SIGNAL(connectionClosed()), this, SIGNAL(connectionClosed())); connect(d_socket, SIGNAL(delayedCloseFinished()), this, SIGNAL(delayedCloseFinished())); connect(d_socket, SIGNAL(readyRead()), this, SIGNAL(readyRead())); - connect(d_socket, SIGNAL(error(int)), this, SIGNAL(error(int))); + connect(d_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError))); connect(d_socket, SIGNAL(SocketState(int)), this, SIGNAL(SocketState(int))); } Modified: trunk/qterm-qt4/src/qtermsocket.h =================================================================== --- trunk/qterm-qt4/src/qtermsocket.h 2008-11-27 21:48:13 UTC (rev 554) +++ trunk/qterm-qt4/src/qtermsocket.h 2008-11-27 21:49:03 UTC (rev 555) @@ -49,7 +49,7 @@ void connectionClosed(); void delayedCloseFinished(); void readyRead(); - void error(int); + void error(QAbstractSocket::SocketError); void SocketState(int); protected slots: @@ -107,7 +107,7 @@ void connectionClosed(); void delayedCloseFinished(); void readyRead(); - void error(int); + void error(QAbstractSocket::SocketError); void SocketState(int); }; Modified: trunk/qterm-qt4/src/qtermtelnet.cpp =================================================================== --- trunk/qterm-qt4/src/qtermtelnet.cpp 2008-11-27 21:48:13 UTC (rev 554) +++ trunk/qterm-qt4/src/qtermtelnet.cpp 2008-11-27 21:49:03 UTC (rev 555) @@ -113,8 +113,8 @@ this, SLOT( connected() ) ); connect ( socket, SIGNAL( readyRead() ), this, SLOT( socketReadyRead() ) ); - connect ( socket, SIGNAL( error( int ) ), - this, SLOT( showError( int ) ) ); + connect ( socket, SIGNAL( error(QAbstractSocket::SocketError) ), + this, SLOT( showError(QAbstractSocket::SocketError) ) ); connect ( socket, SIGNAL( hostFound() ), this, SLOT( hostFound() ) ); connect ( socket, SIGNAL( delayedCloseFinished() ), @@ -304,7 +304,7 @@ * SLOT error *------------------------------------------------------------------------ */ -void Telnet::showError( int index ) +void Telnet::showError( QAbstractSocket::SocketError index ) { switch ( index ) Modified: trunk/qterm-qt4/src/qtermtelnet.h =================================================================== --- trunk/qterm-qt4/src/qtermtelnet.h 2008-11-27 21:48:13 UTC (rev 554) +++ trunk/qterm-qt4/src/qtermtelnet.h 2008-11-27 21:49:03 UTC (rev 555) @@ -3,6 +3,7 @@ #include <QtCore/QObject> #include <QtCore/QByteArray> +#include <QtNetwork/QAbstractSocket> #ifndef u_char #define u_char uchar @@ -132,7 +133,7 @@ private slots: void connected(); void socketReadyRead(); - void showError( int ); + void showError(QAbstractSocket::SocketError); void hostFound (); void delayCloseFinished(); void closed(); Modified: trunk/qterm-qt4/src/ssh/socket.cpp =================================================================== --- trunk/qterm-qt4/src/ssh/socket.cpp 2008-11-27 21:48:13 UTC (rev 554) +++ trunk/qterm-qt4/src/ssh/socket.cpp 2008-11-27 21:49:03 UTC (rev 555) @@ -175,6 +175,7 @@ //connect(m_socket, SIGNAL(connected()), this, SIGNAL(connected())); connect(m_socket, SIGNAL(connectionClosed()), this, SIGNAL(connectionClosed())); connect(m_socket, SIGNAL(delayedCloseFinished()), this, SIGNAL(delayedCloseFinished())); + connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError))); connect(m_socket, SIGNAL(SocketState(int)), this, SIGNAL(SocketState(int))); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-11-28 03:48:27
|
Revision: 565 http://qterm.svn.sourceforge.net/qterm/?rev=565&view=rev Author: hephooey Date: 2008-11-28 03:48:22 +0000 (Fri, 28 Nov 2008) Log Message: ----------- Upgrade function for old config files Modified Paths: -------------- trunk/qterm-qt4/src/qtermconfig.cpp trunk/qterm-qt4/src/qtermconfig.h Modified: trunk/qterm-qt4/src/qtermconfig.cpp =================================================================== --- trunk/qterm-qt4/src/qtermconfig.cpp 2008-11-28 03:48:17 UTC (rev 564) +++ trunk/qterm-qt4/src/qtermconfig.cpp 2008-11-28 03:48:22 UTC (rev 565) @@ -52,9 +52,48 @@ if (!m_settings->contains("version")) { m_settings->setValue("version", m_version); } + addShortcuts(); + addToolBars(); save(); } +void Config::addShortcuts() +{ + if (hasSection("Shortcuts")) + return; + m_settings->beginGroup("Shortcuts"); + m_settings->setValue("actionAbout","F1"); + m_settings->setValue("actionAddress","F2"); + m_settings->setValue("actionQuickConnect","F3"); + m_settings->setValue("actionRefresh","F5"); + m_settings->setValue("actionFull","F6"); + m_settings->setValue("actionScriptRun","F7"); + m_settings->setValue("actionScriptStop","F8"); + m_settings->setValue("actionCopyArticle","F9"); + m_settings->setValue("actionViewMessage","F10"); + m_settings->setValue("actionBoss","F12"); + m_settings->setValue("actionCopy","Ctrl+Ins"); + m_settings->setValue("actionPaste","Shift+Ins"); + m_settings->endGroup(); +} + +void Config::addToolBars() +{ + if (hasSection("ToolBars")) + return; + m_settings->beginGroup("ToolBars"); + QStringList listActions; + listActions << "actionQuickConnect"; + m_settings->setValue("mainToolBar", listActions); + listActions.clear(); + listActions << "actionDisconnect" << "Separator" << "actionCopy" << "actionPaste" << "actionRect" << "actionColorCopy" << "Separator" << "actionFont" << "actionColor" << "actionRefresh" << "Separator" << "actionCurrentSession" << "Separator" << "actionCopyArticle" << "actionAntiIdle" << "actionAutoReply" << "actionViewMessage" << "actionMouse" << "actionBeep" << "actionReconnect"; + m_settings->setValue("bbsOperationsToolBar",listActions); + m_settings->setValue("mainToolBarShown", true); + m_settings->setValue("customKeyToolBarShown", true); + m_settings->setValue("bbsOperationsToolBarShown",true); + m_settings->endGroup(); +} + bool Config::checkVersion() { QString version = m_settings->value("version").toString(); @@ -65,7 +104,7 @@ } else if (m_version != version) { QMessageBox::warning(0, "Version Mismath","The version of your config file is not match the current QTerm version.\n" "It will be automatically updated, but you should check for errors"); m_settings->setValue("version", m_version); - save(); + upgrade(); return false; } return true; Modified: trunk/qterm-qt4/src/qtermconfig.h =================================================================== --- trunk/qterm-qt4/src/qtermconfig.h 2008-11-28 03:48:17 UTC (rev 564) +++ trunk/qterm-qt4/src/qtermconfig.h 2008-11-28 03:48:22 UTC (rev 565) @@ -31,6 +31,8 @@ bool checkError(); bool checkVersion(); void upgrade(); + void addShortcuts(); + void addToolBars(); static const QString m_version; QSettings * m_settings; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-12-12 22:51:02
|
Revision: 574 http://qterm.svn.sourceforge.net/qterm/?rev=574&view=rev Author: hephooey Date: 2008-12-12 22:50:57 +0000 (Fri, 12 Dec 2008) Log Message: ----------- DBus deserves a class for its own. Modified Paths: -------------- trunk/qterm-qt4/src/CMakeLists.txt trunk/qterm-qt4/src/qtermframe.cpp trunk/qterm-qt4/src/qtermglobal.cpp trunk/qterm-qt4/src/qtermglobal.h trunk/qterm-qt4/src/qtermwindow.cpp Added Paths: ----------- trunk/qterm-qt4/src/dbus.cpp trunk/qterm-qt4/src/dbus.h Modified: trunk/qterm-qt4/src/CMakeLists.txt =================================================================== --- trunk/qterm-qt4/src/CMakeLists.txt 2008-12-12 22:50:46 UTC (rev 573) +++ trunk/qterm-qt4/src/CMakeLists.txt 2008-12-12 22:50:57 UTC (rev 574) @@ -38,6 +38,7 @@ aboutdialog.cpp addrdialog.cpp articledialog.cpp + dbus.cpp imageviewer.cpp keydialog.cpp main.cpp Added: trunk/qterm-qt4/src/dbus.cpp =================================================================== --- trunk/qterm-qt4/src/dbus.cpp (rev 0) +++ trunk/qterm-qt4/src/dbus.cpp 2008-12-12 22:50:57 UTC (rev 574) @@ -0,0 +1,163 @@ +#include "dbus.h" +#include <QtDBus> +#include <QtDebug> + +namespace QTerm +{ +DBus * DBus::m_instance = 0; +static const QString dbusServiceName = "org.kde.VisualNotifications"; +static const QString dbusInterfaceName = "org.kde.VisualNotifications"; +static const QString dbusPath = "/VisualNotifications"; + +DBus * DBus::instance() +{ + static QMutex mutex; + if (!m_instance) { + mutex.lock(); + + if (!m_instance) + m_instance = new DBus; + + mutex.unlock(); + } + + return m_instance; +} + +DBus::DBus() + :m_dbusAvailable(false),m_idList() +{ + m_idList.clear(); + QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface(); + m_dbusAvailable = interface && interface->isServiceRegistered(dbusServiceName); + + if( m_dbusAvailable) { + qDebug() << "using" << dbusServiceName << "for popups"; + createDBusConnection(); + } + + // to catch register/unregister events from service in runtime + connect(interface, SIGNAL(serviceOwnerChanged(const QString&, const QString&, const QString&)), this, SLOT(slotServiceOwnerChanged(const QString&, const QString&, const QString&))); + +} + +void DBus::createDBusConnection() +{ + bool connected = QDBusConnection::sessionBus().connect(QString(), // from any service + dbusPath, + dbusInterfaceName, + "ActionInvoked", + this, + SLOT(slotDBusNotificationActionInvoked(uint,const QString&))); + if (!connected) { + qDebug() << "warning: failed to connect to NotificationClosed dbus signal"; + } + connected = QDBusConnection::sessionBus().connect(QString(), // from any service + dbusPath, + dbusInterfaceName, + "NotificationClosed", + this, + SLOT(slotDBusNotificationClosed(uint,uint))); + if (!connected) { + qDebug() << "warning: failed to connect to NotificationClosed dbus signal"; + } +} + +void DBus::slotServiceOwnerChanged( const QString & serviceName, const QString & oldOwner, const QString & newOwner ) +{ + if(serviceName == dbusServiceName) + { + if(oldOwner.isEmpty()) + { + m_idList.clear(); + m_dbusAvailable = true; + qDebug() << dbusServiceName << " was registered on bus, now using it to show popups"; + // connect to action invocation signals + createDBusConnection(); + } + if(newOwner.isEmpty()) + { + m_idList.clear(); + m_dbusAvailable = false; + qDebug() << dbusServiceName << " was unregistered from bus, using passive popups from now on"; + } + } +} + +bool DBus::sendDBusNotification(const QString & summary, const QString & body, QList<DBus::Action> actions) +{ + QDBusMessage message = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "Notify" ); + uint id = 0; + QList<QVariant> args; + args.append("QTerm"); + args.append(id); // If I send 0 directly, this will be an int32 instead of uin32, resulting an unknown method error. + args.append(QString()); + args.append(QString()); + args.append(summary); + args.append(body); + QStringList actionList; + foreach (DBus::Action action, actions) { + if (action==DBus::Show_QTerm) { + actionList.append(QString::number(DBus::Show_QTerm)); + actionList.append("Show QTerm"); + } + } + args.append(actionList); + args.append(QVariantMap()); + args.append(6*1000); + message.setArguments(args); + QDBusMessage replyMsg = QDBusConnection::sessionBus().call(message); + if(replyMsg.type() == QDBusMessage::ReplyMessage) { + if (!replyMsg.arguments().isEmpty()) { + uint dbus_id = replyMsg.arguments().at(0).toUInt(); + m_idList.append(dbus_id); + } else { + qDebug() << "error: received reply with no arguments"; + } + } else if (replyMsg.type() == QDBusMessage::ErrorMessage) { + qDebug() << "error: failed to send dbus message"; + } else { + qDebug() << "unexpected reply type"; + } + //TODO: handle errors + return true; +} + +void DBus::slotDBusNotificationActionInvoked(uint id, const QString action) +{ + if (m_idList.contains(id)) { + if (action.toInt() == DBus::Show_QTerm) { + closeNotification(id); + emit showQTerm(); + } + } +} + +void DBus::slotDBusNotificationClosed(uint id, uint reason) +{ + if (m_idList.contains(id)) + m_idList.removeAll(id); +} + +void DBus::closeNotification(uint id) +{ + if (m_idList.contains(id)) { + m_idList.removeAll(id); + QDBusMessage m = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "CloseNotification" ); + QList<QVariant> args; + args.append(id); + m.setArguments( args ); + bool queued = QDBusConnection::sessionBus().send(m); + if (!queued) { + qDebug() << "warning: failed to queue dbus message"; + } + } +} + +bool DBus::dbusExist() const +{ + return m_dbusAvailable; +} + +} // namespace QTerm +#include <dbus.moc> Added: trunk/qterm-qt4/src/dbus.h =================================================================== --- trunk/qterm-qt4/src/dbus.h (rev 0) +++ trunk/qterm-qt4/src/dbus.h 2008-12-12 22:50:57 UTC (rev 574) @@ -0,0 +1,50 @@ +// +// C++ Interface: Global +// +// Description: +// +// +// Author: hooey <hep...@gm...>, (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef DBUS_H +#define DBUS_H + +#include "qtermparam.h" + +#include <QtCore/QMutex> +#include <QtCore/QString> +#include <QtCore/QMap> +#include <QtCore/QObject> + +namespace QTerm +{ +class DBus: public QObject +{ + Q_OBJECT +public: + enum Action { + Show_QTerm + }; + static DBus * instance(); + bool dbusExist() const; + bool sendDBusNotification(const QString & summary, const QString & body, QList<DBus::Action> actions); +signals: + void showQTerm(); +private slots: + void slotServiceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner); + void slotDBusNotificationActionInvoked(uint id, const QString action); + void slotDBusNotificationClosed(uint id, uint reason); +private: + DBus(); + void createDBusConnection(); + void closeNotification(uint id); + static DBus * m_instance; + bool m_dbusAvailable; + QList<uint> m_idList; +}; + +} +#endif // DBUS_H Modified: trunk/qterm-qt4/src/qtermframe.cpp =================================================================== --- trunk/qterm-qt4/src/qtermframe.cpp 2008-12-12 22:50:46 UTC (rev 573) +++ trunk/qterm-qt4/src/qtermframe.cpp 2008-12-12 22:50:57 UTC (rev 574) @@ -28,6 +28,7 @@ #include "imageviewer.h" #include "shortcutsdialog.h" #include "toolbardialog.h" +#include "dbus.h" #include <QPaintEvent> #include <QMouseEvent> @@ -87,7 +88,8 @@ tray = 0; trayMenu = 0; Global::instance()->setParent(this); - connect(Global::instance(), SIGNAL(showQTerm()), this, SLOT(slotShowQTerm())); + DBus::instance()->setParent(this); + connect(DBus::instance(), SIGNAL(showQTerm()), this, SLOT(slotShowQTerm())); //create a tabbar in the hbox tabBar = new QTabBar(statusBar()); Modified: trunk/qterm-qt4/src/qtermglobal.cpp =================================================================== --- trunk/qterm-qt4/src/qtermglobal.cpp 2008-12-12 22:50:46 UTC (rev 573) +++ trunk/qterm-qt4/src/qtermglobal.cpp 2008-12-12 22:50:57 UTC (rev 574) @@ -21,7 +21,6 @@ #include <QtGui/QApplication> #include <QtGui/QFileDialog> #include <QtGui/QMessageBox> -#include <QtDBus> #if defined(_OS_WIN32_) || defined(Q_OS_WIN32) #ifndef MAX_PATH @@ -55,7 +54,7 @@ } Global::Global() - : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_fullScreen(false), m_dbusAvailable(false), m_language(Global::English),m_idList(), m_showToolBar() + : m_fileCfg("./qterm.cfg"), m_addrCfg("./address.cfg"), m_pathLib("./"), m_pathPic("./"), m_pathCfg("./"), m_windowState(), m_status(INIT_OK), m_style(), m_fullScreen(false), m_language(Global::English), m_showToolBar() { if (!iniWorkingDir(qApp->arguments()[0])) { m_status = INIT_ERROR; @@ -67,7 +66,6 @@ m_status = INIT_ERROR; return; } - initDBus(); } bool Global::isOK() @@ -809,139 +807,6 @@ } } -bool Global::dbusExist() const -{ - return m_dbusAvailable; -} - -void Global::createDBusConnection() -{ - bool connected = QDBusConnection::sessionBus().connect(QString(), // from any service - dbusPath, - dbusInterfaceName, - "ActionInvoked", - this, - SLOT(slotDBusNotificationActionInvoked(uint,const QString&))); - if (!connected) { - qDebug() << "warning: failed to connect to NotificationClosed dbus signal"; - } - connected = QDBusConnection::sessionBus().connect(QString(), // from any service - dbusPath, - dbusInterfaceName, - "NotificationClosed", - this, - SLOT(slotDBusNotificationClosed(uint,uint))); - if (!connected) { - qDebug() << "warning: failed to connect to NotificationClosed dbus signal"; - } -} - -void Global::initDBus() -{ - m_idList.clear(); - QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface(); - m_dbusAvailable = interface && interface->isServiceRegistered(dbusServiceName); - - if( m_dbusAvailable) { - qDebug() << "using" << dbusServiceName << "for popups"; - createDBusConnection(); - } - - // to catch register/unregister events from service in runtime - connect(interface, SIGNAL(serviceOwnerChanged(const QString&, const QString&, const QString&)), this, SLOT(slotServiceOwnerChanged(const QString&, const QString&, const QString&))); -} - -void Global::slotServiceOwnerChanged( const QString & serviceName, const QString & oldOwner, const QString & newOwner ) -{ - if(serviceName == dbusServiceName) - { - if(oldOwner.isEmpty()) - { - m_idList.clear(); - m_dbusAvailable = true; - qDebug() << dbusServiceName << " was registered on bus, now using it to show popups"; - // connect to action invocation signals - createDBusConnection(); - } - if(newOwner.isEmpty()) - { - m_idList.clear(); - m_dbusAvailable = false; - qDebug() << dbusServiceName << " was unregistered from bus, using passive popups from now on"; - } - } -} - -bool Global::sendDBusNotification(const QString & summary, const QString & body, QList<Global::Action> actions) -{ - QDBusMessage message = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "Notify" ); - uint id = 0; - QList<QVariant> args; - args.append("QTerm"); - args.append(id); // If I send 0 directly, this will be an int32 instead of uin32, resulting an unknown method error. - args.append(QString()); - args.append(QString()); - args.append(summary); - args.append(body); - QStringList actionList; - foreach (Global::Action action, actions) { - if (action==Global::Show_QTerm) { - actionList.append(QString::number(Global::Show_QTerm)); - actionList.append("Show QTerm"); - } - } - args.append(actionList); - args.append(QVariantMap()); - args.append(6*1000); - message.setArguments(args); - QDBusMessage replyMsg = QDBusConnection::sessionBus().call(message); - if(replyMsg.type() == QDBusMessage::ReplyMessage) { - if (!replyMsg.arguments().isEmpty()) { - uint dbus_id = replyMsg.arguments().at(0).toUInt(); - m_idList.append(dbus_id); - } else { - qDebug() << "error: received reply with no arguments"; - } - } else if (replyMsg.type() == QDBusMessage::ErrorMessage) { - qDebug() << "error: failed to send dbus message"; - } else { - qDebug() << "unexpected reply type"; - } - //TODO: handle errors - return true; -} - -void Global::slotDBusNotificationActionInvoked(uint id, const QString action) -{ - if (m_idList.contains(id)) { - if (action.toInt() == Global::Show_QTerm) { - closeNotification(id); - emit showQTerm(); - } - } -} - -void Global::slotDBusNotificationClosed(uint id, uint reason) -{ - if (m_idList.contains(id)) - m_idList.removeAll(id); -} - -void Global::closeNotification(uint id) -{ - if (m_idList.contains(id)) { - m_idList.removeAll(id); - QDBusMessage m = QDBusMessage::createMethodCall( dbusServiceName, dbusPath, dbusInterfaceName, "CloseNotification" ); - QList<QVariant> args; - args.append(id); - m.setArguments( args ); - bool queued = QDBusConnection::sessionBus().send(m); - if (!queued) { - qDebug() << "warning: failed to queue dbus message"; - } - } -} - } // namespace QTerm #include <qtermglobal.moc> Modified: trunk/qterm-qt4/src/qtermglobal.h =================================================================== --- trunk/qterm-qt4/src/qtermglobal.h 2008-12-12 22:50:46 UTC (rev 573) +++ trunk/qterm-qt4/src/qtermglobal.h 2008-12-12 22:50:57 UTC (rev 574) @@ -39,9 +39,6 @@ INIT_OK, INIT_ERROR }; - enum Action { - Show_QTerm - }; struct Pref { Codec nXIM; int nWordWrap; @@ -86,7 +83,6 @@ bool isFullScreen() const; bool showSwitchBar() const; bool showToolBar(const QString & toolbar); - bool dbusExist() const; const QString & style() const; void setClipCodec(Codec codecId); @@ -107,21 +103,12 @@ void saveGeometry( const QByteArray geometry); void saveState( const QByteArray state); void cleanup(); - bool sendDBusNotification(const QString & summary, const QString & body, QList<Global::Action> actions); -signals: - void showQTerm(); -private slots: - void slotServiceOwnerChanged(const QString & serviceName, const QString & oldOwner, const QString & newOwner); - void slotDBusNotificationActionInvoked(uint id, const QString action); - void slotDBusNotificationClosed(uint id, uint reason); private: Global(); static Global* m_Instance; bool iniWorkingDir(QString param); bool iniSettings(); - void initDBus(); - void createDBusConnection(); bool isPathExist(const QString & path); bool createLocalFile(const QString & dst, const QString & src); void closeNotification(uint id); @@ -142,9 +129,7 @@ Position m_scrollPos; bool m_fullScreen; bool m_switchBar; - bool m_dbusAvailable; Language m_language; - QList<uint> m_idList; QMap<QString, bool> m_showToolBar; }; Modified: trunk/qterm-qt4/src/qtermwindow.cpp =================================================================== --- trunk/qterm-qt4/src/qtermwindow.cpp 2008-12-12 22:50:46 UTC (rev 573) +++ trunk/qterm-qt4/src/qtermwindow.cpp 2008-12-12 22:50:57 UTC (rev 574) @@ -37,6 +37,7 @@ #include "progressBar.h" #include "qtermglobal.h" #include "hostinfo.h" +#include "dbus.h" #if !defined(_OS_WIN32_) && !defined(Q_OS_WIN32) #include <unistd.h> @@ -1064,10 +1065,10 @@ if(!isActiveWindow() || m_pFrame->wndmgr->activeWindow()!=this) { - if (Global::instance()->dbusExist()) { - QList<Global::Action> actions; - actions.append(Global::Show_QTerm); - Global::instance()->sendDBusNotification("New Message in QTerm", fromBBSCodec(strMsg.toLatin1()),actions); + if (DBus::instance()->dbusExist()) { + QList<DBus::Action> actions; + actions.append(DBus::Show_QTerm); + DBus::instance()->sendDBusNotification("New Message in QTerm", fromBBSCodec(strMsg.toLatin1()),actions); } else { m_popWin->setText(fromBBSCodec(strMsg.toLatin1())); m_popWin->popup(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hep...@us...> - 2008-12-12 22:51:12
|
Revision: 576 http://qterm.svn.sourceforge.net/qterm/?rev=576&view=rev Author: hephooey Date: 2008-12-12 22:51:08 +0000 (Fri, 12 Dec 2008) Log Message: ----------- Correct header Modified Paths: -------------- trunk/qterm-qt4/src/dbus.cpp trunk/qterm-qt4/src/dbus.h Modified: trunk/qterm-qt4/src/dbus.cpp =================================================================== --- trunk/qterm-qt4/src/dbus.cpp 2008-12-12 22:51:02 UTC (rev 575) +++ trunk/qterm-qt4/src/dbus.cpp 2008-12-12 22:51:08 UTC (rev 576) @@ -1,3 +1,15 @@ +// +// C++ Implementation: DBus +// +// Description: +// +// +// Author: hooey <hep...@gm...>, (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// + #include "dbus.h" #include <QtDBus> #include <QtDebug> Modified: trunk/qterm-qt4/src/dbus.h =================================================================== --- trunk/qterm-qt4/src/dbus.h 2008-12-12 22:51:02 UTC (rev 575) +++ trunk/qterm-qt4/src/dbus.h 2008-12-12 22:51:08 UTC (rev 576) @@ -1,5 +1,5 @@ // -// C++ Interface: Global +// C++ Interface: DBus // // Description: // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |