Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Set a webpage as homepage #30

Closed
wants to merge 2 commits into from

2 participants

@rsiebert

The user can now define a webpage as its homepage in the bookmark manager screen. When the browser is started this homepage is automatically loaded. A jumppoint to load the homepage directly is also available. The second commit is also included and changes a page scroll from 100% to 95%.

rsiebert added some commits
@rsiebert rsiebert Reduced the scroll amount from a page up or down command to 100% to 9…
…5%. This removes the need to scroll again to read the text that is on a page boundary.
53fab6f
@rsiebert rsiebert The user can now define a homepage in the bookmark manager screen. A …
…jumppoint to load the homepage directly is also available.
39d7788
@rsiebert

This is an update to the ticket 8398 (http://code.mythtv.org/trac/ticket/8398).

@rsiebert

Any chance of getting this PR included?

@stuartm
Owner

Committed in [bb8c246] - Feb 2014

@stuartm stuartm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2012
  1. @rsiebert

    Reduced the scroll amount from a page up or down command to 100% to 9…

    rsiebert authored
    …5%. This removes the need to scroll again to read the text that is on a page boundary.
  2. @rsiebert

    The user can now define a homepage in the bookmark manager screen. A …

    rsiebert authored
    …jumppoint to load the homepage directly is also available.
This page is out of date. Refresh to see the latest.
View
12 mythplugins/mythbrowser/mythbrowser/bookmarkeditor.cpp
@@ -23,6 +23,7 @@ BookmarkEditor::BookmarkEditor(Bookmark *site, bool edit,
m_siteCategory(), m_editing(edit),
m_titleText(NULL), m_categoryEdit(NULL),
m_nameEdit(NULL), m_urlEdit(NULL),
+ m_isHomepage(NULL),
m_okButton(NULL), m_cancelButton(NULL),
m_findCategoryButton(NULL), m_searchDialog(NULL)
{
@@ -61,6 +62,7 @@ bool BookmarkEditor::Create()
m_categoryEdit = dynamic_cast<MythUITextEdit *> (GetChild("category"));
m_nameEdit = dynamic_cast<MythUITextEdit *> (GetChild("name"));
m_urlEdit = dynamic_cast<MythUITextEdit *> (GetChild("url"));
+ m_isHomepage = dynamic_cast<MythUICheckBox *> (GetChild("homepage"));
m_okButton = dynamic_cast<MythUIButton *> (GetChild("ok"));
m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
@@ -68,7 +70,7 @@ bool BookmarkEditor::Create()
m_findCategoryButton = dynamic_cast<MythUIButton *> (GetChild("findcategory"));
if (!m_categoryEdit || !m_nameEdit || !m_urlEdit || !m_okButton
- || !m_cancelButton || !m_findCategoryButton)
+ || !m_isHomepage || !m_cancelButton || !m_findCategoryButton)
{
LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
return false;
@@ -83,6 +85,8 @@ bool BookmarkEditor::Create()
m_categoryEdit->SetText(m_site->category);
m_nameEdit->SetText(m_site->name);
m_urlEdit->SetText(m_site->url);
+ if (m_site->isHomepage)
+ m_isHomepage->SetCheckState(MythUIStateType::Full);
}
BuildFocusList();
@@ -117,13 +121,17 @@ void BookmarkEditor::Save()
if (m_editing && m_siteCategory != "" && m_siteName != "")
RemoveFromDB(m_siteCategory, m_siteName);
- InsertInDB(m_categoryEdit->GetText(), m_nameEdit->GetText(), m_urlEdit->GetText());
+ ResetHomepageFromDB();
+ bool isHomepage = (m_isHomepage->GetCheckState() == MythUIStateType::Full) ? true : false;
+
+ InsertInDB(m_categoryEdit->GetText(), m_nameEdit->GetText(), m_urlEdit->GetText(), isHomepage);
if (m_site)
{
m_site->category = m_categoryEdit->GetText();
m_site->name = m_nameEdit->GetText();
m_site->url = m_urlEdit->GetText();
+ m_site->isHomepage = isHomepage;
}
Exit();
View
2  mythplugins/mythbrowser/mythbrowser/bookmarkeditor.h
@@ -7,6 +7,7 @@
#include <mythuibutton.h>
#include <mythuitext.h>
#include <mythuitextedit.h>
+#include <mythuicheckbox.h>
class Bookmark;
@@ -38,6 +39,7 @@ class BookmarkEditor : public MythScreenType
MythUITextEdit *m_categoryEdit;
MythUITextEdit *m_nameEdit;
MythUITextEdit *m_urlEdit;
+ MythUICheckBox *m_isHomepage;
MythUIButton *m_okButton;
MythUIButton *m_cancelButton;
View
27 mythplugins/mythbrowser/mythbrowser/bookmarkmanager.cpp
@@ -245,6 +245,8 @@ void BookmarkManager::UpdateURLList(void)
m_bookmarkList, "", "", true, MythUIButtonListItem::NotChecked);
item->SetText(site->name, "name");
item->SetText(site->url, "url");
+ if (site->isHomepage)
+ item->DisplayState("yes", "homepage");
item->SetData(qVariantFromValue(site));
item->setChecked(site->selected ?
MythUIButtonListItem::FullChecked : MythUIButtonListItem::NotChecked);
@@ -298,6 +300,7 @@ bool BookmarkManager::keyPressEvent(QKeyEvent *event)
m_menuPopup->SetReturnEvent(this, "action");
+ m_menuPopup->AddButton(tr("Set Homepage"), SLOT(slotSetHomepage()));
m_menuPopup->AddButton(tr("Add Bookmark"), SLOT(slotAddBookmark()));
if (m_bookmarkList->GetItemCurrent())
@@ -476,6 +479,30 @@ void BookmarkManager::ReloadBookmarks(void)
}
}
+void BookmarkManager::slotSettings(void)
+{
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+ BrowserConfig *config = new BrowserConfig(mainStack, "browserconfig");
+ if (config->Create())
+ mainStack->AddScreen(config);
+}
+
+void BookmarkManager::slotSetHomepage(void)
+{
+ // Clear all homepage information
+ ResetHomepageFromDB();
+
+ // Set the homepage information for selected bookmark
+ MythUIButtonListItem *item = m_bookmarkList->GetItemCurrent();
+ if (item && item->GetData().isValid())
+ {
+ Bookmark *site = qVariantValue<Bookmark*>(item->GetData());
+ if (site)
+ UpdateHomepageInDB(site);
+ }
+ ReloadBookmarks();
+}
+
void BookmarkManager::slotAddBookmark(void)
{
ShowEditDialog(false);
View
4 mythplugins/mythbrowser/mythbrowser/bookmarkmanager.h
@@ -15,12 +15,14 @@ class Bookmark
category = "";
name = "";
url = "";
+ isHomepage = false;
selected = false;
}
QString category;
QString name;
QString url;
+ bool isHomepage;
bool selected;
inline bool operator == (const Bookmark &b) const
@@ -76,6 +78,8 @@ class BookmarkManager : public MythScreenType
void slotDoDeleteMarked(bool doDelete);
void slotBrowserClosed(void);
+ void slotSettings(void);
+ void slotSetHomepage(void);
void slotAddBookmark(void);
void slotEditBookmark(void);
void slotDeleteCurrent(void);
View
43 mythplugins/mythbrowser/mythbrowser/browserdbutil.cpp
@@ -9,7 +9,7 @@
#include "browserdbutil.h"
#include "bookmarkmanager.h"
-const QString currentDatabaseVersion = "1002";
+const QString currentDatabaseVersion = "1003";
static bool UpdateDBVersionNumber(const QString &newnumber)
{
@@ -111,6 +111,17 @@ bool UpgradeBrowserDatabaseSchema(void)
return false;
}
+ if (dbver == "1002")
+ {
+ const QString updates[] =
+ {
+ "ALTER TABLE `websites` ADD `homepage` BOOL NOT NULL;",
+ ""
+ };
+ if (!performActualUpdate(updates, "1003", dbver))
+ return false;
+ }
+
return true;
}
@@ -130,16 +141,34 @@ bool FindInDB(const QString &category, const QString& name)
return (query.size() > 0);
}
+bool ResetHomepageFromDB()
+{
+ MSqlQuery query(MSqlQuery::InitCon());
+ query.prepare("UPDATE `websites` SET `homepage` = '0' WHERE `homepage` = '1';");
+ return query.exec();
+}
+
+bool UpdateHomepageInDB(Bookmark* site)
+{
+ MSqlQuery query(MSqlQuery::InitCon());
+ query.prepare("UPDATE `websites` SET `homepage` = '1' "
+ "WHERE `category` = :CATEGORY "
+ "AND `name` = :NAME;");
+ query.bindValue(":CATEGORY", site->category);
+ query.bindValue(":NAME", site->name);
+ return query.exec();
+}
+
bool InsertInDB(Bookmark* site)
{
if (!site)
return false;
- return InsertInDB(site->category, site->name, site->url);
+ return InsertInDB(site->category, site->name, site->url, site->isHomepage);
}
bool InsertInDB(const QString &category,
- const QString &name, const QString &url)
+ const QString &name, const QString &url, const bool &isHomepage)
{
if (category.isEmpty() || name.isEmpty() || url.isEmpty())
return false;
@@ -155,11 +184,12 @@ bool InsertInDB(const QString &category,
_url.replace("&amp;","&");
MSqlQuery query(MSqlQuery::InitCon());
- query.prepare("INSERT INTO websites (category, name, url) "
- "VALUES(:CATEGORY, :NAME, :URL);");
+ query.prepare("INSERT INTO websites (category, name, url, homepage) "
+ "VALUES(:CATEGORY, :NAME, :URL, :HOMEPAGE);");
query.bindValue(":CATEGORY", category);
query.bindValue(":NAME", name);
query.bindValue(":URL", _url);
+ query.bindValue(":HOMEPAGE", isHomepage);
if (!query.exec())
{
MythDB::DBError("mythbrowser: inserting in DB", query);
@@ -222,7 +252,7 @@ int GetSiteList(QList<Bookmark*> &siteList)
MSqlQuery query(MSqlQuery::InitCon());
- if (!query.exec("SELECT category, name, url FROM websites "
+ if (!query.exec("SELECT category, name, url, homepage FROM websites "
"ORDER BY category, name"))
{
LOG(VB_GENERAL, LOG_ERR, "BookmarkManager: Error in loading from DB");
@@ -235,6 +265,7 @@ int GetSiteList(QList<Bookmark*> &siteList)
site->category = query.value(0).toString();
site->name = query.value(1).toString();
site->url = query.value(2).toString();
+ site->isHomepage = query.value(3).toBool();
site->selected = false;
siteList.append(site);
}
View
5 mythplugins/mythbrowser/mythbrowser/browserdbutil.h
@@ -9,7 +9,10 @@ bool UpgradeBrowserDatabaseSchema(void);
bool FindInDB(const QString &category, const QString& name);
bool InsertInDB(Bookmark *site);
-bool InsertInDB(const QString &category, const QString &name, const QString &url);
+bool InsertInDB(const QString &category, const QString &name, const QString &url, const bool &isHomepage);
+
+bool ResetHomepageFromDB();
+bool UpdateHomepageInDB(Bookmark* site);
bool RemoveFromDB(Bookmark *site);
bool RemoveFromDB(const QString &category, const QString &name);
View
46 mythplugins/mythbrowser/mythbrowser/main.cpp
@@ -61,6 +61,47 @@ static int handleMedia(const QString &url, const QString &directory, const QStri
return 0;
}
+static void runBookmarkManager()
+{
+ mythplugin_run();
+}
+
+/** \fn runHomepage()
+ * \brief Loads the specified homepage from the database (the name starts
+ with an underscore) and calls handleMedia() if it exists.
+ * \return void.
+ */
+static void runHomepage()
+{
+ // Get the homepage from the database. The url
+ // that is set as a homepage starts with a space.
+ MSqlQuery query(MSqlQuery::InitCon());
+
+ if (!query.exec("SELECT url FROM `websites` WHERE `homepage` = true;"))
+ LOG(VB_GENERAL, LOG_ERR, "Error loading homepage from DB");
+
+ if (query.size() > 0)
+ {
+ query.next();
+ handleMedia( query.value(0).toString(), "", "", "", "", 0, 0, "", 0, "", "", false);
+ }
+ else
+ {
+ // show a dialog that no homepage is specified
+ QString message = "No homepage was specified.\n"
+ "If required you can do this in the bookmark manager";
+
+ MythScreenStack *m_popupStack =
+ GetMythMainWindow()->GetStack("popup stack");
+
+ MythConfirmationDialog *okPopup =
+ new MythConfirmationDialog(m_popupStack, message, false);
+
+ if (okPopup->Create())
+ m_popupStack->AddScreen(okPopup);
+ }
+}
+
static void setupKeys(void)
{
REG_KEY("Browser", "NEXTTAB", QT_TRANSLATE_NOOP("MythControls",
@@ -70,6 +111,11 @@ static void setupKeys(void)
REG_MEDIAPLAYER("WebBrowser", QT_TRANSLATE_NOOP("MythControls",
"Internal Web Browser"), handleMedia);
+
+ REG_JUMP("Bookmarks", QT_TRANSLATE_NOOP("MythControls",
+ "Show the bookmark manager"), "", runBookmarkManager);
+ REG_JUMP("Homepage", QT_TRANSLATE_NOOP("MythControls",
+ "Show the webbrowser homepage"), "", runHomepage);
}
int mythplugin_init(const char *libversion)
View
14 mythplugins/mythbrowser/theme/default-wide/browser-ui.xml
@@ -286,13 +286,23 @@
<position>395,340</position>
</textedit>
+ <textarea name="homepagelabel" from="basetextarea">
+ <area>180,450,200,30</area>
+ <align>right,vcenter</align>
+ <value>Homepage:</value>
+ </textarea>
+
+ <checkbox name="homepage" from="basecheckbox">
+ <position>395,440</position>
+ </checkbox>
+
<button name="cancel" from="basebutton">
- <position>395,480</position>
+ <position>395,530</position>
<value>Cancel</value>
</button>
<button name="ok" from="basebutton">
- <position>620,480</position>
+ <position>620,530</position>
<value>OK</value>
</button>
View
14 mythplugins/mythbrowser/theme/default/browser-ui.xml
@@ -274,13 +274,23 @@
<position>195,340</position>
</textedit>
+ <textarea name="homepagelabel" from="basetextarea">
+ <area>80,450,100,30</area>
+ <align>right,vcenter</align>
+ <value>Homepage:</value>
+ </textarea>
+
+ <checkbox name="homepage" from="basecheckbox">
+ <position>195,440</position>
+ </checkbox>
+
<button name="cancel" from="basebutton">
- <position>60,480</position>
+ <position>60,530</position>
<value>Cancel</value>
</button>
<button name="ok" from="basebutton">
- <position>590,480</position>
+ <position>590,530</position>
<value>OK</value>
</button>
View
4 mythtv/libs/libmythui/mythuiwebbrowser.cpp
@@ -1521,11 +1521,11 @@ bool MythUIWebBrowser::keyPressEvent(QKeyEvent *event)
}
else if (action == "PAGEUP")
{
- Scroll(0, -m_browserArea.height());
+ Scroll(0, -m_browserArea.height() * 19 / 20);
}
else if (action == "PAGEDOWN")
{
- Scroll(0, m_browserArea.height());
+ Scroll(0, m_browserArea.height() * 19 / 20);
}
else if (action == "ZOOMIN")
{
Something went wrong with that request. Please try again.