|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "appmainshell.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "application.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfarmcontroller.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/colors.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/menubar.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/event.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/action.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "traster.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tenv.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tgrid.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/tabbedwindow.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "taskstatuspage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "serverstatuspage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "casmsubmitpage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "submitpage.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "filebrowserpopup.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tw/message.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace TwConsts;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class MyTabbedWindow : public TTabbedWindow
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
MyTabbedWindow(TWidget *parent) : TTabbedWindow(parent) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void leftButtonDown(const TMouseEvent &e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TabPage *page1 = dynamic_cast<tabpage *="">(getCurrentPanel());</tabpage>
|
|
Toshihiro Shimizu |
890ddd |
TTabbedWindow::leftButtonDown(e);
|
|
Toshihiro Shimizu |
890ddd |
TabPage *page2 = dynamic_cast<tabpage *="">(getCurrentPanel());</tabpage>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (page1 != page2)
|
|
Toshihiro Shimizu |
890ddd |
if (page1)
|
|
Toshihiro Shimizu |
890ddd |
page1->onDeactivate();
|
|
Toshihiro Shimizu |
890ddd |
if (page2)
|
|
Toshihiro Shimizu |
890ddd |
page2->onActivate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class AppMainshell::Data
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
Data()
|
|
Toshihiro Shimizu |
890ddd |
: m_tabbedWindow(0), m_menubar(0), m_updatePeriod(3000), m_retryCount(0), m_retryPeriod(15000) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
MyTabbedWindow *m_tabbedWindow;
|
|
Toshihiro Shimizu |
890ddd |
TMenubar *m_menubar;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int m_updatePeriod;
|
|
Toshihiro Shimizu |
890ddd |
int m_retryCount;
|
|
Toshihiro Shimizu |
890ddd |
int m_retryPeriod;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TEnv::RootSystemVar systemVar(TFilePath("SOFTWARE\\Digital Video\\ToonzFarm\\1.0\\LOCALROOT"));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void errorMessage(const string &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TMessage::error(msg);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const int menuBarLy = 21;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // anonymous namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
AppMainshell::AppMainshell() : TMainshell("mainshell")
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_name = "TFarmClient, v1.0 alfa - " +
|
|
Toshihiro Shimizu |
890ddd |
TSystem::getUserName() + "@" + TSystem::getHostName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_data = new Data;
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tabbedWindow = new MyTabbedWindow(this);
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tabbedWindow->addPanel(new TaskStatusPage(m_data->m_tabbedWindow));
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tabbedWindow->addPanel(new ServerStatusPage(m_data->m_tabbedWindow));
|
|
Toshihiro Shimizu |
890ddd |
//m_data->m_tabbedWindow->addPanel(new CasmSubmitPage(m_data->m_tabbedWindow));
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tabbedWindow->addPanel(new SubmitPage(m_data->m_tabbedWindow));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_menubar = new TMenubar(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMenubarItem *menu = new TMenubarItem(m_data->m_menubar, "File");
|
|
Toshihiro Shimizu |
890ddd |
menu->addItem("Quit");
|
|
Toshihiro Shimizu |
890ddd |
TGuiCommand("Quit").setAction(
|
|
Toshihiro Shimizu |
890ddd |
new TCommandAction<appmainshell>(this, close));</appmainshell>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
menu = new TMenubarItem(m_data->m_menubar, "Tasks");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
menu->addItem("Casm");
|
|
Toshihiro Shimizu |
890ddd |
TGuiCommand("Casm").setAction(new TCommandAction<appmainshell>(this, onTaskCasm));</appmainshell>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
menu->addItem("Notepad");
|
|
Toshihiro Shimizu |
890ddd |
TGuiCommand("Notepad").setAction(new TCommandAction<appmainshell>(this, onTaskNotepad));</appmainshell>
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
AppMainshell::~AppMainshell()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
HANDLE HFile;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AppMainshell::init()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TSystem::loadStandardPlugins();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
Application::instance()->init();
|
|
Toshihiro Shimizu |
890ddd |
} catch (TException &e) {
|
|
Toshihiro Shimizu |
890ddd |
TMessage::error(toString(e.getMessage()));
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool AppMainshell::beforeShow()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!Application::instance()->testControllerConnection()) {
|
|
Toshihiro Shimizu |
890ddd |
string hostName, addr;
|
|
Toshihiro Shimizu |
890ddd |
int port;
|
|
Toshihiro Shimizu |
890ddd |
Application::instance()->getControllerData(hostName, addr, port);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
string msg("Unable to connect to the ToonzFarm Controller\n");
|
|
Toshihiro Shimizu |
890ddd |
msg += "The Controller should run on " + hostName + " at port ";
|
|
Toshihiro Shimizu |
890ddd |
msg += toString(port) + "\n";
|
|
Toshihiro Shimizu |
890ddd |
msg += "Please start the Controller before running this application";
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMessage::error(msg);
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TWidget *w = m_data->m_tabbedWindow->getCurrentPanel();
|
|
Toshihiro Shimizu |
890ddd |
TabPage *page = dynamic_cast<tabpage *="">(w);</tabpage>
|
|
Toshihiro Shimizu |
890ddd |
if (page)
|
|
Toshihiro Shimizu |
890ddd |
page->onActivate();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
startTimer(m_data->m_updatePeriod);
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AppMainshell::configureNotify(const TDimension &size)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TMainshell::configureNotify(size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tabbedWindow->setGeometry(0, 0, size.lx - 1, size.ly - menuBarLy - 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_menubar->setGeometry(0, size.ly - menuBarLy, size.lx - 1, size.ly - 1);
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_menubar->invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AppMainshell::close()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (TMessage::question("Are you sure?") == TMessage::YES) {
|
|
Toshihiro Shimizu |
890ddd |
TMainshell::close();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AppMainshell::repaint()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TDimension size = getSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int y = size.ly - 1;
|
|
Toshihiro Shimizu |
890ddd |
int x = 20;
|
|
Toshihiro Shimizu |
890ddd |
setColor(White);
|
|
Toshihiro Shimizu |
890ddd |
fillRect(x, 0, size.lx - 1, y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
setColor(Gray60);
|
|
Toshihiro Shimizu |
890ddd |
fillRect(0, 0, x - 1, y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
y -= 21;
|
|
Toshihiro Shimizu |
890ddd |
drawLine(x, y, x, y - 3);
|
|
Toshihiro Shimizu |
890ddd |
drawLine(x + 1, y, x + 1, y - 1);
|
|
Toshihiro Shimizu |
890ddd |
drawLine(x + 2, y, x + 3, y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDimension AppMainshell::getPreferredSize()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TDimension(1200, 500);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int AppMainshell::getMainIconId()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return 101 /*IDI_ZCOMP*/;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AppMainshell::onTimer(int)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (false && !Application::instance()->testControllerConnection()) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_data->m_retryCount == 0) {
|
|
Toshihiro Shimizu |
890ddd |
stopTimer();
|
|
Toshihiro Shimizu |
890ddd |
startTimer(m_data->m_retryPeriod);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
++m_data->m_retryCount;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_data->m_retryCount == 3) {
|
|
Toshihiro Shimizu |
890ddd |
stopTimer();
|
|
Toshihiro Shimizu |
890ddd |
startTimer(4 * m_data->m_retryPeriod);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
string hostName, addr;
|
|
Toshihiro Shimizu |
890ddd |
int port;
|
|
Toshihiro Shimizu |
890ddd |
Application::instance()->getControllerData(hostName, addr, port);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
string msg("The connection to the ToonzFarm Controller has been lost\n");
|
|
Toshihiro Shimizu |
890ddd |
msg += "The Controller should run on " + hostName + " at port ";
|
|
Toshihiro Shimizu |
890ddd |
msg += toString(port) + "\n";
|
|
Toshihiro Shimizu |
890ddd |
msg += "Please check the Controller state";
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMessage::error(msg);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
if (m_data->m_retryCount > 0) {
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_retryCount = 0;
|
|
Toshihiro Shimizu |
890ddd |
string msg("Reconnected to the ToonzFarm Controller\n");
|
|
Toshihiro Shimizu |
890ddd |
TMessage::error(msg);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
stopTimer();
|
|
Toshihiro Shimizu |
890ddd |
startTimer(m_data->m_updatePeriod);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TWidget *w = m_data->m_tabbedWindow->getCurrentPanel();
|
|
Toshihiro Shimizu |
890ddd |
TabPage *page = dynamic_cast<tabpage *="">(w);</tabpage>
|
|
Toshihiro Shimizu |
890ddd |
if (page)
|
|
Toshihiro Shimizu |
890ddd |
page->update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
AppMainshell mainshell;
|