00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <stdlib.h>
00015 #include <kapplication.h>
00016 #include <kcmdlineargs.h>
00017 #include <klocale.h>
00018 #include "tabview.h"
00019
00020 #include "mythtv/exitcodes.h"
00021 #include "mythtv/mythcontext.h"
00022 #include "mythtv/mythdbcon.h"
00023 #include "mythtv/langsettings.h"
00024
00025
00026 static const char *version = "v0.32";
00027
00028 static KCmdLineOptions options[] = {
00029 { "zoom ",0,0},
00030 { "z ","Zoom factor 20-300 (default: 200)", "200"},
00031 { "x ","X position of window (default: 0)", "0"},
00032 { "y ","Y position of window (default: 0)", "0"},
00033 { "w ","Screen width (default: physical screen width)", 0 },
00034 { "h ","Screen height (default: physical screen height)", 0 },
00035 { "g" ,"Run in windowed mode", 0 },
00036 { "+file ","URLs to display", 0 },
00037 KCmdLineLastOption
00038 };
00039
00040 void setupKeys(void)
00041 {
00042 REG_KEY("Browser", "NEXTTAB", "Move to next browser tab", "P");
00043 REG_KEY("Browser", "PREVTAB", "Move to previous browser tab", "");
00044 REG_KEY("Browser", "DELETETAB", "Delete the current browser tab", "D");
00045
00046 REG_KEY("Browser", "ZOOMIN", "Zoom in on browser window", ".,>");
00047 REG_KEY("Browser", "ZOOMOUT", "Zoom out on browser window", ",,<");
00048 REG_KEY("Browser", "TOGGLEINPUT", "Toggle where keyboard input goes to", "F1");
00049
00050 REG_KEY("Browser", "MOUSEUP", "Move mouse pointer up", "2");
00051 REG_KEY("Browser", "MOUSEDOWN", "Move mouse pointer down", "8");
00052 REG_KEY("Browser", "MOUSELEFT", "Move mouse pointer left", "4");
00053 REG_KEY("Browser", "MOUSERIGHT", "Move mouse pointer right", "6");
00054 REG_KEY("Browser", "MOUSELEFTBUTTON", "Mouse Left button click", "5");
00055
00056 REG_KEY("Browser", "PAGEDOWN", "Scroll down half a page", "9");
00057 REG_KEY("Browser", "PAGEUP", "Scroll up half a page", "3");
00058 REG_KEY("Browser", "PAGELEFT", "Scroll left half a page", "7");
00059 REG_KEY("Browser", "PAGERIGHT", "Scroll right half a page", "1");
00060
00061 REG_KEY("Browser", "NEXTLINK", "Move selection to next link", "Z");
00062 REG_KEY("Browser", "PREVIOUSLINK", "Move selection to previous link", "Q");
00063 REG_KEY("Browser", "FOLLOWLINK", "Follow selected link", "Return,Space,Enter");
00064 REG_KEY("Browser", "BACK", "Go back to previous page", "R,Backspace");
00065 }
00066
00067 int main(int argc, char **argv)
00068 {
00069 bool windowed = false;
00070 int x = 0, y = 0;
00071 float xm = 0, ym = 0;
00072 int zoom,width=-1,height=-1;
00073 char usage[] = "Usage: mythbrowser [-z n] [-g] [-x n] [-y n] [-w n] [-h n] -u URL [URL]";
00074 QStringList urls;
00075
00076 KCmdLineArgs::init(argc, argv, "mythbrowser", "mythbrowser", usage , version);
00077 KCmdLineArgs::addCmdLineOptions(options);
00078 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00079 zoom = args->getOption("z").toInt();
00080 if (args->isSet("w"))
00081 width = args->getOption("w").toInt();
00082 if (args->isSet("h"))
00083 height = args->getOption("h").toInt();
00084 if (args->isSet("x"))
00085 x = args->getOption("x").toInt();
00086 if (args->isSet("y"))
00087 y = args->getOption("y").toInt();
00088 if (args->isSet("g"))
00089 windowed = true;
00090
00091 for (int i=0;i<args->count();i++)
00092 {
00093 urls += args->arg(i);
00094 }
00095 args->clear();
00096
00097 if (urls.count() == 0)
00098 urls += "http://www.mythtv.org";
00099
00100 KApplication a(argc,argv);
00101
00102 gContext = NULL;
00103 gContext = new MythContext(MYTH_BINARY_VERSION);
00104 if (!gContext->Init(true))
00105 {
00106 VERBOSE(VB_IMPORTANT, "MythBrowser: Could not initialize myth context. Exiting.");
00107 return FRONTEND_EXIT_NO_MYTHCONTEXT;
00108 }
00109
00110 if (width == -1 || height == -1)
00111 {
00112
00113 gContext->GetScreenSettings(x, width, xm, y, height, ym);
00114 }
00115
00116 gContext->ParseGeometryOverride(QString("%1x%2+%3+%4")
00117 .arg(width).arg(height).arg(x).arg(y));
00118
00119 if (windowed)
00120 gContext->OverrideSettingForSession("RunFrontendInWindow", "1");
00121
00122 if (!MSqlQuery::testDBConnection())
00123 {
00124 VERBOSE(VB_IMPORTANT, "MythBrowser: Couldn't open db. Exiting.");
00125 return FRONTEND_EXIT_DB_ERROR;
00126 }
00127
00128 LanguageSettings::load("mythbrowser");
00129
00130 gContext->LoadQtConfig();
00131 setupKeys();
00132
00133 MythMainWindow *mainWindow = GetMythMainWindow();
00134 mainWindow->Init();
00135 gContext->SetMainWindow(mainWindow);
00136
00137 TabView *tabView =
00138 new TabView(mainWindow, "mythbrowser", urls, zoom, width, height,
00139 Qt::WStyle_Customize | Qt::WStyle_NoBorder);
00140 tabView->exec();
00141
00142 return 0;
00143 }