Changeset 2965

Show
Ignore:
Timestamp:
04/27/06 20:21:03 (3 years ago)
Author:
madcat
Message:

Fixed bugs with the new server status info bar.
Skin for server status bar and comments area.
Support for connecting to servers via double-clicking.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hydranode/hngui/commentframe.ui

    r2930 r2965  
    2424   </property> 
    2525   <item row="0" column="0" > 
    26     <widget class="QFrame" name="frame" > 
     26    <widget class="QFrame" name="commentHeaderF" > 
    2727     <property name="maximumSize" > 
    2828      <size> 
     
    5656      <item row="0" column="1" > 
    5757       <widget class="QLabel" name="commentHeader" > 
     58        <property name="minimumSize" > 
     59         <size> 
     60          <width>100</width> 
     61          <height>0</height> 
     62         </size> 
     63        </property> 
    5864        <property name="text" > 
    5965         <string>Known file names and comments</string> 
  • hydranode/hngui/plugins/donkeypage.cpp

    r2959 r2965  
    2626#include <limits> 
    2727#include <QPainter> 
     28#include <boost/lexical_cast.hpp> 
    2829 
    2930// DonkeyStatusBar class 
     
    3132 
    3233void DonkeyStatusBar::paintEvent(QPaintEvent *evt) { 
    33         QFrame::paintEvent(evt); 
    34         QPainter p(this); 
    35         p.setPen(Qt::white); 
    36         p.setBrush(Qt::white); 
    37         p.drawRect(0, 0, width(), height()); 
     34//      QFrame::paintEvent(evt); 
     35        QSettings conf(confDir() + "gui.ini", QSettings::IniFormat); 
     36        if (conf.value("EnableBars").toBool()) { 
     37                QPainter p(this); 
     38                QPixmap img(imgDir() + "plugins/donkeyserverbar.png"); 
     39                if (!img.isNull()) { 
     40                        p.drawPixmap( 
     41                                0, 0, img.scaled( 
     42                                        width(), height(),  
     43                                        Qt::IgnoreAspectRatio,  
     44                                        Qt::SmoothTransformation 
     45                                ) 
     46                        ); 
     47                } else { 
     48                        logDebug("failed to load image donkeyserverbar.png"); 
     49                } 
     50        } else { 
     51                logDebug("Skin is disabled."); 
     52        } 
    3853} 
    3954 
     
    4762        h->setObjectName("ed2k-serverlist"); 
    4863        setHeader(h); 
     64        h->setFocusPolicy(Qt::NoFocus); 
    4965        setBackground(QPixmap(":/backgrounds/backgrounds/default.png")); 
    5066} 
     
    127143// DonkeyPage class 
    128144DonkeyPage::DonkeyPage(QWidget *parent, Engine::Modules *p)  
    129 : QWidget(parent), m_currentServer()
     145: QWidget(parent), m_currentServer(), m_curServerId()
    130146        m_ui = new Ui::DonkeyPage; 
    131147        m_ui->setupUi(this); 
     
    152168        p->removedObject.connect( 
    153169                boost::bind(&DonkeyPage::delObject, this, _1) 
     170        ); 
     171        connect( 
     172                m_ui->serverList,  
     173                SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),  
     174                SLOT(connectToServer(QTreeWidgetItem*, int)) 
    154175        ); 
    155176} 
     
    191212                        } 
    192213                        m_currentServer = cur; 
     214                        m_curServerId = cur->m_data->getId(); 
    193215                        QString statusText(status + " to " + cur->text(0)); 
    194216                        statusText += " (" +formatNumber(cur->text(3).toUInt()); 
     
    196218                        statusText += formatNumber(cur->text(4).toUInt()); 
    197219                        statusText += " files)"; 
    198                         if (status != "Connecting") { 
     220                        if (status != "Connecting" && status != "Logging in") { 
    199221                                statusText += " with "; 
    200222                                if (id.toUInt() <= 0x00ffffff) { 
     
    209231                        logDebug("CurServer: " + curServer); 
    210232                        logDebug("ID: " + id); 
    211                         m_ui->statusText->setText( 
    212                                 "No status information available." 
    213                         ); 
     233                        QString statusText(status + " to "); 
     234                        statusText += "<i>unknown server</i> "; 
     235                        if (status != "Connecting" && status != "Logging in") { 
     236                                statusText += " with "; 
     237                                if (id.toUInt() <= 0x00ffffff) { 
     238                                        statusText += "Low Id"; 
     239                                } else { 
     240                                        statusText += "High Id"; 
     241                                } 
     242                        } 
     243                        m_ui->statusText->setText(statusText); 
     244                        m_curServerId = curServer.toUInt(); 
     245                        m_currentServer = 0; 
    214246                } 
    215247                return; 
     
    230262        ); 
    231263        updateNetworkInfo(); 
     264        if (m_currentServer && obj == m_currentServer->m_data) { 
     265                updateObject(m_serverList); 
     266        } 
    232267} 
    233268 
    234269void DonkeyPage::addObject(Engine::ObjectPtr obj) { 
    235         logDebug("Adding object..."); 
    236270        if (obj->getParent() && obj->getParent()->getName() == "serverlist") { 
    237                 logDebug(" -> adding [add-real]"); 
    238271                ServerListItem *it = new ServerListItem(m_ui->serverList); 
     272                it->m_data = obj; 
    239273                for (int j = 3; j < m_ui->serverList->columnCount(); ++j) { 
    240274                        it->setTextAlignment(j, Qt::AlignRight); 
     
    249283                } 
    250284                m_list[obj->getId()] = it; 
     285                if (!m_currentServer && obj->getId() == m_curServerId) { 
     286                        updateObject(m_serverList); 
     287                } 
    251288        } 
    252289} 
    253290 
    254291void DonkeyPage::delObject(Engine::ObjectPtr obj) { 
    255         logDebug("Removing object..."); 
    256292        QMap<quint32, ServerListItem*>::iterator it =m_list.find(obj->getId()); 
    257293        if (it != m_list.end()) { 
    258                 logDebug(" -> removing [del-real]"); 
    259294                if (m_currentServer == it.value()) { 
    260295                        m_currentServer = 0; 
     
    287322        m_ui->fileCount->setText("Files: " + formatNumber(files)); 
    288323} 
     324 
     325void DonkeyPage::connectToServer(QTreeWidgetItem *it, int) { 
     326        ServerListItem *server = dynamic_cast<ServerListItem*>(it); 
     327        if (!server) { 
     328                return; 
     329        } 
     330        std::map<std::string, std::string> args; 
     331        args["id"] = boost::lexical_cast<std::string>(server->m_data->getId()); 
     332        m_serverList->doOper("connectId", args); 
     333} 
  • hydranode/hngui/plugins/donkeypage.h

    r2959 r2965  
    4949        ServerListItem(QTreeWidget *parent); 
    5050        bool operator<(const QTreeWidgetItem &o) const; 
     51        Engine::ObjectPtr m_data; 
    5152}; 
    5253 
     
    5556public: 
    5657        DonkeyPage(QWidget *parent, Engine::Modules *p); 
     58public Q_SLOTS: 
     59        void connectToServer(QTreeWidgetItem *it, int col); 
    5760private: 
    5861        void gotServers(Engine::ObjectPtr obj); 
     
    6972        Engine::ObjectPtr m_serverList; 
    7073        ServerListItem *m_currentServer; 
     74        quint32 m_curServerId; 
    7175}; 
    7276 
  • hydranode/hngui/plugins/donkeypage_ui.ui

    r2959 r2965  
    1010    <y>0</y> 
    1111    <width>515</width> 
    12     <height>428</height> 
     12    <height>422</height> 
    1313   </rect> 
    1414  </property> 
     
    138138         </sizepolicy> 
    139139        </property> 
     140        <property name="minimumSize" > 
     141         <size> 
     142          <width>100</width> 
     143          <height>0</height> 
     144         </size> 
     145        </property> 
    140146        <property name="text" > 
    141147         <string>No status information available.</string> 
  • hydranode/hngui/settingstabs.ui

    r2939 r2965  
    4040      <size> 
    4141       <width>16</width> 
    42        <height>388</height> 
     42       <height>355</height> 
    4343      </size> 
    4444     </property> 
  • hydranode/hngui/transfertabs.cpp

    r2955 r2965  
    3838// CommentList class 
    3939// ----------------- 
    40 CommentList::CommentList(QWidget *parent) : HTreeWidget(parent) {} 
     40CommentList::CommentList(QWidget *parent) : HTreeWidget(parent) { 
     41        m_commentB = QPixmap(imgDir() + "commentsback.png"); 
     42        m_commentBOrig = m_commentB; 
     43
    4144 
    4245void CommentList::paintEvent(QPaintEvent *evt) { 
    4346        HTreeWidget::paintEvent(evt); 
     47        if (m_commentB.width() != width() || m_commentB.height() != height()) { 
     48                m_commentB = m_commentBOrig.scaled( 
     49                        width(), height(), Qt::IgnoreAspectRatio, 
     50                        Qt::SmoothTransformation 
     51                ); 
     52        } 
     53        QSettings conf(confDir() + "gui.ini", QSettings::IniFormat); 
     54        if (conf.value("EnableBars").toBool()) { 
     55                QPainter p(viewport()); 
     56                p.drawPixmap(0, 0, m_commentB); 
     57        } 
    4458//      QPainter p(viewport()); 
    4559//      QPixmap btn(imgDir() + "opendetails.png"); 
     
    172186        m_commentFrame->commentList->installEventFilter(this); 
    173187        m_commentFrame->commentList->viewport()->installEventFilter(this); 
    174         m_ui->commentFrame->installEventFilter(this); 
     188        m_commentFrame->commentHeaderF->installEventFilter(this); 
    175189        window()->installEventFilter(this); 
    176190        updateButtons(); 
     
    194208        m_actionBack = QPixmap(imgDir() + "actionback.png"); 
    195209//      m_detailsBack = QPixmap(imgDir() + "detailsback.png"); 
     210        m_commentH = QPixmap(imgDir() + "commentsheader.png"); 
     211        m_commentHOrig = m_commentH; 
    196212        m_actionBackOrig = m_actionBack; 
    197213//      m_detailsBackOrig = m_detailsBack; 
     
    433449        QSettings conf(confDir() + "gui.ini", QSettings::IniFormat); 
    434450        if (obj == m_ui->actionBar && !m_actionBack.isNull()) { 
    435                 QPainter p(m_ui->actionBar); 
    436451                if (conf.value("EnableBars").toBool()){ 
     452                        QPainter p(m_ui->actionBar); 
    437453                        int w = m_ui->actionBar->width(); 
    438454                        int h = m_ui->actionBar->height(); 
     
    447463                        } 
    448464                        p.drawPixmap(0, 0, m_actionBack); 
     465                } 
     466        } else if (obj == m_commentFrame->commentHeaderF) { 
     467                if (!m_commentH.isNull()&&conf.value("EnableBars").toBool()){ 
     468                        QPainter p(m_commentFrame->commentHeaderF); 
     469                        int w = m_commentFrame->commentHeaderF->width(); 
     470                        int h = m_commentFrame->commentHeaderF->height(); 
     471                        if ( 
     472                                m_commentH.width() != w || 
     473                                m_commentH.height() != h 
     474                        ) { 
     475                                m_commentH = m_commentHOrig.scaled( 
     476                                        w, h, Qt::IgnoreAspectRatio, 
     477                                        Qt::SmoothTransformation 
     478                                ); 
     479                        } 
     480                        p.drawPixmap(0, 0, m_commentH); 
    449481                } 
    450482//      } else if (obj == m_ui->detailsBar) { 
  • hydranode/hngui/transfertabs.h

    r2939 r2965  
    4343protected: 
    4444        void paintEvent(QPaintEvent *evt); 
     45private: 
     46        QPixmap m_commentB, m_commentBOrig; 
    4547}; 
    4648 
     
    99101        QPixmap m_actionBack, m_actionBackOrig; 
    100102//      QPixmap m_detailsBack, m_detailsBackOrig; 
     103        QPixmap m_commentH, m_commentHOrig; 
    101104        DownloadListItem *m_currentActive; 
    102105        boost::signals::scoped_connection m_currentConnection;