guck

Vim-like QtWebEngine-powered browser, written in C++
git clone git://git.deurzen.net/guck
Log | Files | Refs | LICENSE

url.cc (1062B)


      1 #include "url.hh"
      2 
      3 #include "../../util.hh"
      4 
      5 
      6 void
      7 url_t::update()
      8 {
      9     if (!m_hover.isEmpty()) {
     10         textbase_t::setText(m_hover.toString());
     11         m_type = urltype_t::hover;
     12     } else if (!m_loaded.isEmpty()) {
     13         textbase_t::setText(m_loaded.toString());
     14         m_type = m_status;
     15     } else {
     16         textbase_t::setText("");
     17         m_type = urltype_t::normal;
     18     }
     19 }
     20 
     21 void
     22 url_t::on_tab_change(QUrl url) // tab changed
     23 {
     24 
     25 }
     26 
     27 void
     28 url_t::on_status_change() // add loadstatus
     29 {
     30 
     31 }
     32 
     33 void
     34 url_t::on_set_loaded(QUrl url)
     35 {
     36     if (url.isEmpty())
     37         m_loaded.clear();
     38     else if (!url.isValid())
     39         m_loaded = "invalid";
     40     else
     41         m_loaded = safe_displaystring(url);
     42 
     43     m_status = urltype_t::normal;
     44     update();
     45 }
     46 
     47 void
     48 url_t::on_set_hover(std::string& link)
     49 {
     50     if (link.empty()) {
     51         m_hover.clear();
     52     } else {
     53         QUrl url = QUrl(link.c_str());
     54         if (url.isValid())
     55             m_hover = safe_displaystring(url);
     56         else
     57             m_hover = ("(invalid) " + link).c_str();
     58     }
     59 
     60     update();
     61 }