示例#1
0
//! Load color scheme from the given ini file and section name
void StelGui::setStelStyle(const QString& section)
{
	if (currentStelStyle.confSectionName!=section)
	{
		// Load the style sheets
		currentStelStyle.confSectionName = section;

		QString qtStyleFileName = ":/graphicGui/normalStyle.css";
		QString htmlStyleFileName = ":/graphicGui/normalHtml.css";

		// Load Qt style sheet
		QFile styleFile(qtStyleFileName);
		if(styleFile.open(QIODevice::ReadOnly))
		{
			currentStelStyle.qtStyleSheet = styleFile.readAll();
			styleFile.close();
		}

		QFile htmlStyleFile(htmlStyleFileName);
		if(htmlStyleFile.open(QIODevice::ReadOnly))
		{
			currentStelStyle.htmlStyleSheet = htmlStyleFile.readAll();
			htmlStyleFile.close();
		}
	}
	
	locationDialog->styleChanged();
	dateTimeDialog->styleChanged();
	configurationDialog->styleChanged();
	searchDialog->styleChanged();
	viewDialog->styleChanged();
#ifdef ENABLE_SCRIPT_CONSOLE
	scriptConsole->styleChanged();
#endif // ENABLE_SCRIPT_CONSOLE
}
示例#2
0
void AssetManager::loadAssets()
{
    isLoaded = true;

    // load default font
    int id1 = QFontDatabase::addApplicationFont(LIBS_FILEPATH + "/fonts/SourceCodePro-Regular.ttf");
    srcCodeLightFont = QFontDatabase::applicationFontFamilies(id1).at(0);

    int id2 = QFontDatabase::addApplicationFont(LIBS_FILEPATH + "/fonts/Muli-Light.ttf");
    mainAppFont = QFontDatabase::applicationFontFamilies(id2).at(0);

    // load css stylesheets
    QFile styleFile(LIBS_FILEPATH + "/css/default.qss");
    //QFile styleFile(LIBS_FILEPATH + "/css/dark.qss");
    if (!styleFile.exists()) {
            qDebug() << "File " << styleFile.fileName() << " does not exist.";
    }
    styleFile.open( QFile::ReadOnly );
    // Apply the loaded stylesheet
    defaultStyle = styleFile.readAll();
    styleFile.close();

    loadAllLanguageSupport();
    loadAllStyleSheets();
}
示例#3
0
文件: main.cpp 项目: JJ/ARehab
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    Q_INIT_RESOURCE(ARehab_vTerapeuta);

    QSurfaceFormat format;
    format.setVersion(4, 3);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setOption(QSurfaceFormat::DebugContext);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setSamples(4);
    format.setSwapInterval(0); //Disable VSync
    QSurfaceFormat::setDefaultFormat(format);

    ARehabGUIDesigner::ARehabMainWindow w;

    QFile styleFile(":/styles/main.qss");
    styleFile.open(QFile::ReadOnly);
    app.setStyleSheet(QLatin1String(styleFile.readAll()));
    styleFile.close();

    w.show();
    return (app.exec());
}
示例#4
0
void MainWindow::loadApplicationData()
{
    // Loading the headers
    QFile headersFile( m_appDir.absoluteFilePath( QLatin1String("headers.js") ) );
    headersFile.open(QFile::ReadOnly);
    const QString script = QTextStream( &headersFile ).readAll();
    headersFile.close();

    QScriptEngine engine;
    engine.evaluate(script);
    QScriptValue function = engine.globalObject().property( QLatin1String("headers") );

    QStringList headers = function.call().toString().split( QLatin1String(", ") );
    m_table->setColumnCount(headers.size());
    m_table->setHorizontalHeaderLabels(headers);

    // Loading the stylesheet
    if ( m_appDir.exists( QLatin1String("application.qss") ) ) {
        QFile styleFile( m_appDir.absoluteFilePath( QLatin1String("application.qss") ) );
        styleFile.open(QFile::ReadOnly);
        const QString stylesheet = QTextStream( &styleFile ).readAll();
        styleFile.close();
        qApp->setStyleSheet(stylesheet);
    }
    else {
        qApp->setStyleSheet( QString() );
    }
}
示例#5
0
文件: lampview.cpp 项目: vukis/Lamp
void LampView::initializeStyle()
{
    // Load an application style
    QFile styleFile(QApplication::applicationName()+"_theme.qss");
    if(styleFile.open(QFile::ReadOnly)) {
        // Apply stylesheet
        qApp->setStyleSheet(styleFile.readAll());
    }
}
示例#6
0
文件: main.cpp 项目: alexvrn/projects
QString loadStyleSheet(QString path)
{
    QFile styleFile(path);
    QString styleSheet = QString();
    if( styleFile.open(QFile::ReadOnly) )
    {
        styleSheet = QLatin1String(styleFile.readAll());
    }
    return styleSheet;
}
示例#7
0
/**
 * Initialize vim
 *
 * - Set default colors
 * - Create window and shell
 * - Read settings
 */
int
gui_mch_init()
{

	window = new MainWindow(&gui);

	// Load qVim settings
	QSettings settings("Vim", "qVim");
	settings.beginGroup("mainwindow");
	window->restoreState( settings.value("state").toByteArray() );
	window->resize( settings.value("size", QSize(400, 400)).toSize() );
	settings.endGroup();

	vimshell = window->vimShell();

	// Load qVim style
	QSettings ini(QSettings::IniFormat, QSettings::UserScope, "Vim", "qVim");
	QFile styleFile( QFileInfo(ini.fileName()).absoluteDir().absoluteFilePath("qVim.style") );

	if ( styleFile.open(QIODevice::ReadOnly) ) {
		window->setStyleSheet( styleFile.readAll() );
		styleFile.close();
	}

	// Clipboard - the order matters, for safety
	clip_plus.clipboardMode = QClipboard::Selection;
	clip_star.clipboardMode = QClipboard::Clipboard;

	QObject::connect(QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)),
			vimshell, SLOT(clipboardChanged(QClipboard::Mode)));


	display_errors();

	/* Colors */
	gui.norm_pixel = VimWrapper::toColor(QColor(Qt::black));
	gui.back_pixel = VimWrapper::toColor(QColor(Qt::white));

	set_normal_colors();
	gui_check_colors();
	highlight_gui_started();

	gui.def_norm_pixel = VimWrapper::toColor(QColor(Qt::black));
	gui.def_back_pixel = VimWrapper::toColor(QColor(Qt::white));

	// The Scrollbar manages the scrollbars
	gui.scrollbar_width = 0;
	gui.scrollbar_height = 0;

	// Background color hint
	vimshell->setBackground(VimWrapper::backgroundColor() );

	return OK;
}
示例#8
0
QString AssetManager::loadStyleSheetByFilename(QString filename)
{
    // load css stylesheets
    QFile styleFile(filename);
    if (!styleFile.exists()) {
            qDebug() << "File " << styleFile.fileName() << " does not exist.";
    }
    styleFile.open( QFile::ReadOnly );
    // Apply the loaded stylesheet
    QString style = styleFile.readAll();
    styleFile.close();

    return style;
}
示例#9
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QFile styleFile(":/stylesheet.qss");
    if(styleFile.open(QIODevice::ReadOnly))
    {
        QTextStream textStream(&styleFile);
        QString styleSheet = textStream.readAll();
        styleFile.close();
        a.setStyleSheet(styleSheet);
    }
    AppController controller;
    return a.exec();
}
示例#10
0
文件: lampview.cpp 项目: vukis/Lamp
void LampView::onActionChooseStyle()
{
    // File dialog to choose stylesheet file
    QFileDialog dialog;
    dialog.setNameFilter(tr("Styles (*.qss)"));
     if(dialog.exec()) {
        QString fileName = dialog.selectedFiles().first();
        // Load an application style
        QFile styleFile(fileName);
        if(styleFile.open(QFile::ReadOnly))
            // Apply stylesheet
            qApp->setStyleSheet(styleFile.readAll());
    }
}
示例#11
0
int main(int argc, char *argv[])
{
QApplication app(argc, argv);


// Load style sheet
QFile styleFile( qApp->applicationDirPath() + "/qss/lhc.qss" );
styleFile.open( QFile::ReadOnly );

// Apply the loaded stylesheet
QString style( styleFile.readAll() );
app.setStyleSheet( style );




qApp->addLibraryPath( qApp->applicationDirPath() + "/plugins");



QTranslator translator;

PMSettings *pmsettings = new PMSettings();
translator.load("translations/lhc_"+pmsettings->getAttributeSettings("language")+".qm");
delete pmsettings;

app.installTranslator(&translator);

//Inicijuojam DB
QCoreApplication::setOrganizationName("Remdex");
QCoreApplication::setOrganizationDomain("remdex.info");
QCoreApplication::setApplicationName("Live helper chat");

LoginDialog *lgnDialog = new LoginDialog(0,true);

if(!lgnDialog->exec())
{
    QTimer::singleShot(250, qApp, SLOT(quit()));
}

delete lgnDialog;


MainWindow w;
w.show();
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
	return app.exec();

}
示例#12
0
    std::shared_ptr<utymap::mapcss::StyleProvider> getStyleProvider(const std::string& filePath)
    {
        auto pair = styleProviders_.find(filePath);
        if (pair != styleProviders_.end())
            return pair->second;

        std::ifstream styleFile(filePath);
        if (!styleFile.good())
            throw std::invalid_argument(std::string("Cannot read mapcss file:") + filePath);

        // NOTE not safe, but don't want to use boost filesystem only for this task.
        std::string dir = filePath.substr(0, filePath.find_last_of("\\/") + 1);
        utymap::mapcss::MapCssParser parser(dir);
        utymap::mapcss::StyleSheet stylesheet = parser.parse(styleFile);
        styleProviders_[filePath] = std::make_shared<utymap::mapcss::StyleProvider>(stylesheet, stringTable_);
        return styleProviders_[filePath];
    }
示例#13
0
int main(int argc, char *argv[])
{
    // Load an application style
    QFile styleFile(".\\styles\\stylesheet_black_orange.css");
    styleFile.open( QFile::ReadOnly );

    // Apply the loaded stylesheet
    QString style( styleFile.readAll() );


    QApplication a(argc, argv);
    a.setStyleSheet(style);
    MainWindow w;
    w.show();

    return a.exec();
}
示例#14
0
void QtStyleManager::ReadStyleData(ExtStyle* style)
{
  QString tabStyleFileName(style->fileName);
  QString activeTabStyleFileName(style->fileName);

  int index = style->fileName.lastIndexOf(".qss");
  tabStyleFileName.replace(index, 4, "-tab.qss");
  activeTabStyleFileName.replace(index, 4, "-activetab.qss");

  QFile styleFile(style->fileName);
  if (styleFile.open(QIODevice::ReadOnly))
  {
    QTextStream in(&styleFile);
    style->stylesheet = in.readAll();
  }
  else
  {
    BERRY_WARN << "Could not read " << style->fileName.toStdString();
  }

  QFile tabStyleFile(tabStyleFileName);
  if (tabStyleFile.open(QIODevice::ReadOnly))
  {
    QTextStream in(&tabStyleFile);
    style->tabStylesheet = in.readAll();
  }
  else
  {
    BERRY_WARN << "Could not read " << tabStyleFileName.toStdString();
  }

  QFile activeTabStyleFile(activeTabStyleFileName);
  if (activeTabStyleFile.open(QIODevice::ReadOnly))
  {
    QTextStream in(&activeTabStyleFile);
    style->activeTabStylesheet = in.readAll();
  }
  else
  {
    BERRY_WARN << "Could not read " << activeTabStyleFileName.toStdString();
  }
}
示例#15
0
bool OsmAnd::MapStyle_P::parseMetadata()
{
    if(owner->isEmbedded)
    {
        QXmlStreamReader data(EmbeddedResources::decompressResource(owner->resourcePath));
        return parseMetadata(data);
    }
    else
    {
        QFile styleFile(owner->resourcePath);
        if(!styleFile.open(QIODevice::ReadOnly | QIODevice::Text))
            return false;
        QXmlStreamReader data(&styleFile);
        bool ok = parseMetadata(data);
        styleFile.close();
        return ok;
    }

    return false;
}
示例#16
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    ffprobeBin("/usr/local/bin/ffprobe"),
    ffmpegBin("/usr/local/bin/ffmpeg")
    {

    // Load an application style
    QFile styleFile(":/qss/main.css");
    styleFile.open(QFile::ReadOnly);

    // Apply the loaded stylesheet
    QString style(styleFile.readAll());
    this->setStyleSheet(style);

    connect (&commandProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(outputCommand()));
    connect (&commandProcess, SIGNAL(readyReadStandardError()), this, SLOT(outputCommand()));

    ui->setupUi(this);

    videoWidget = new QVideoWidget(ui->graphicsView);
    player = new QMediaPlayer(this);
    //player->setNotifyInterval(1000);
}
示例#17
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    SettingsView w;

    // Load an application style
    QFile styleFile(":/styles/styles/default.qss");
    styleFile.open( QFile::ReadOnly );

    // Apply the loaded stylesheet
    QString style( styleFile.readAll() );
    app.setStyleSheet( style );

//    QFontDatabase fontDB;
//    fontDB.addApplicationFont(":/GraphicsView/fonts");
//    foreach(QString s, fontDB.families())
//    {
//        qDebug() << s;
//    }

    w.show();

    return app.exec();
}
示例#18
0
Widget::Widget() : QWidget(),
      m_label(new QLabel)
{
    setLayout(new QVBoxLayout);
    layout()->addWidget(m_label);

    setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::WindowDoesNotAcceptFocus | Qt::Tool);
    setAttribute(Qt::WA_TranslucentBackground);

    m_label->setTextInteractionFlags(Qt::TextSelectableByKeyboard);
    m_label->setTextFormat(Qt::PlainText);
    m_label->setWordWrap(true);
    layout()->setMargin(0);
    setMaximumWidth(1000);
    setMaximumHeight(1000);
    setMinimumWidth(500);
    setMinimumHeight(128);
    m_label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    m_label->setMargin(5);

    QFont font;
    font.setPixelSize(15);
    setFont(font);

    //connect(qApp->clipboard(), &QClipboard::dataChanged, this, &Widget::onClipboardUpdated);
    connect(qApp->clipboard(), &QClipboard::dataChanged, &m_updateTimer, [=]() { m_updateTimer.start(10); });
    connect(&m_updateTimer, &QTimer::timeout, this, &Widget::onClipboardUpdated);
    m_updateTimer.setSingleShot(true);

    m_timer.setSingleShot(true);
    connect(&m_timer, &QTimer::timeout, this, &QWidget::hide);

     QString stylesheet(
                "QLabel {\n"
                "    border: 3px solid white;\n"
                "    background-color: rgba(0, 0, 0, 128);\n"
                "    selection-color: black;\n"
                "    selection-background-color: white;\n"
                "}\n"
                );

    const QString configLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
    QDir configDir(configLocation);
    if (!configDir.exists()) {
        configDir.mkpath(configLocation);
    }

    QString stylePath = configDir.absoluteFilePath("pastenotifier.qss");
    QFile styleFile(stylePath);
    if (styleFile.exists()) {
        if (styleFile.open(QIODevice::ReadOnly)) {
            qDebug() << "Loading stylesheet" << stylePath;
            stylesheet = QString::fromLocal8Bit(styleFile.readAll());
        } else {
            qWarning() << "Unable to open qss file:" << stylePath << styleFile.errorString();
        }
    } else {
        if (styleFile.open(QIODevice::WriteOnly)) {
            styleFile.write(stylesheet.toUtf8());
        } else {
            qWarning() << "Unable to open qss file for writing:" << stylePath << styleFile.errorString();
        }
    }

    QAction *showAction = new QAction(this);
    connect(showAction, &QAction::triggered, [=](){
        setWindowOpacity(1);
        show();
        m_timer.start(5000);
    });
    showAction->setObjectName("showpastenotifier");
    KGlobalAccel::setGlobalShortcut(showAction, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_V));

    setStyleSheet(stylesheet);

    onClipboardUpdated();
}
示例#19
0
QString QgsMapLayer::loadNamedStyle( const QString &theURI, bool &theResultFlag )
{
  QgsDebugMsg( QString( "uri = %1 myURI = %2" ).arg( theURI ).arg( publicSource() ) );

  theResultFlag = false;

  QDomDocument myDocument( "qgis" );

  // location of problem associated with errorMsg
  int line, column;
  QString myErrorMessage;

  QFile myFile( theURI );
  if ( myFile.open( QFile::ReadOnly ) )
  {
    // read file
    theResultFlag = myDocument.setContent( &myFile, &myErrorMessage, &line, &column );
    if ( !theResultFlag )
      myErrorMessage = tr( "%1 at line %2 column %3" ).arg( myErrorMessage ).arg( line ).arg( column );
    myFile.close();
  }
  else
  {
    QFileInfo project( QgsProject::instance()->fileName() );
    QgsDebugMsg( QString( "project fileName: %1" ).arg( project.absoluteFilePath() ) );

    QString qml;
    if ( loadNamedStyleFromDb( QDir( QgsApplication::qgisSettingsDirPath() ).absoluteFilePath( "qgis.qmldb" ), theURI, qml ) ||
         ( project.exists() && loadNamedStyleFromDb( project.absoluteDir().absoluteFilePath( project.baseName() + ".qmldb" ), theURI, qml ) ) ||
         loadNamedStyleFromDb( QDir( QgsApplication::pkgDataPath() ).absoluteFilePath( "resources/qgis.qmldb" ), theURI, qml ) )
    {
      theResultFlag = myDocument.setContent( qml, &myErrorMessage, &line, &column );
      if ( !theResultFlag )
      {
        myErrorMessage = tr( "%1 at line %2 column %3" ).arg( myErrorMessage ).arg( line ).arg( column );
      }
    }
    else
    {
      myErrorMessage = tr( "style not found in database" );
    }
  }

  if ( !theResultFlag )
  {
    return myErrorMessage;
  }

  // get style file version string, if any
  QgsProjectVersion fileVersion( myDocument.firstChildElement( "qgis" ).attribute( "version" ) );
  QgsProjectVersion thisVersion( QGis::QGIS_VERSION );

  if ( thisVersion > fileVersion )
  {
    QgsLogger::warning( "Loading a style file that was saved with an older "
                        "version of qgis (saved in " + fileVersion.text() +
                        ", loaded in " + QGis::QGIS_VERSION +
                        "). Problems may occur." );

    QgsProjectFileTransform styleFile( myDocument, fileVersion );
    // styleFile.dump();
    styleFile.updateRevision( thisVersion );
    // styleFile.dump();
  }

  // now get the layer node out and pass it over to the layer
  // to deserialise...
  QDomElement myRoot = myDocument.firstChildElement( "qgis" );
  if ( myRoot.isNull() )
  {
    myErrorMessage = tr( "Error: qgis element could not be found in %1" ).arg( theURI );
    theResultFlag = false;
    return myErrorMessage;
  }

  // use scale dependent visibility flag
  toggleScaleBasedVisibility( myRoot.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
  setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
  setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );

#if 0
  //read transparency level
  QDomNode transparencyNode = myRoot.namedItem( "transparencyLevelInt" );
  if ( ! transparencyNode.isNull() )
  {
    // set transparency level only if it's in project
    // (otherwise it sets the layer transparent)
    QDomElement myElement = transparencyNode.toElement();
    setTransparency( myElement.text().toInt() );
  }
#endif

  QString errorMsg;
  theResultFlag = readSymbology( myRoot, errorMsg );
  if ( !theResultFlag )
  {
    myErrorMessage = tr( "Loading style file %1 failed because:\n%2" ).arg( theURI ).arg( errorMsg );
    return myErrorMessage;
  }

  return "";
}
示例#20
0
/**
 * Initialize vim
 *
 * - Set default colors
 * - Create window and shell
 * - Read settings
 */
int
gui_mch_init()
{

#ifdef Q_WS_X11
	bool useGUI = getenv("DISPLAY") != 0;
#else
	bool useGUI = true;
#endif
	QApplication *app = new QApplication(dummy_argc, dummy_argv, useGUI);


	window = new MainWindow(&gui);

	// Load qVim settings
	QSettings settings("Vim", "qVim");
	settings.beginGroup("mainwindow");
	window->restoreState( settings.value("state").toByteArray() );
	settings.endGroup();

	vimshell = window->vimShell();

	// Load qVim style
	QSettings ini(QSettings::IniFormat, QSettings::UserScope, "Vim", "qVim");
	QFile styleFile( QFileInfo(ini.fileName()).absoluteDir().absoluteFilePath("qVim.style") );

	if ( styleFile.open(QIODevice::ReadOnly) ) {
		window->setStyleSheet( styleFile.readAll() );
		styleFile.close();
	}

	//
	// Hide the tab/menu/tool-bars, if needed they will become visible later.
	// Otherwise the use might see these items when Vim is loading
	//
	window->showMenu(false);
	window->showToolbar(false);
	window->showTabline(false);

	// Clipboard - order matters, for safety
	clip_star.clipboardMode = QClipboard::Selection;
	clip_plus.clipboardMode = QClipboard::Clipboard;

	display_errors();

	/* Colors */
	gui.norm_pixel = VimWrapper::toColor(QColor(Qt::black));
	gui.back_pixel = VimWrapper::toColor(QColor(Qt::white));

	set_normal_colors();
	gui_check_colors();
	highlight_gui_started();

	gui.def_norm_pixel = VimWrapper::toColor(QColor(Qt::black));
	gui.def_back_pixel = VimWrapper::toColor(QColor(Qt::white));

	// The Scrollbar manages the scrollbars
	gui.scrollbar_width = 0;
	gui.scrollbar_height = 0;

	// Background color hint
	vimshell->setBackground(VimWrapper::backgroundColor() );

	if ( start_fullscreen ) {
		gui_mch_enter_fullscreen();
	}

	return OK;
}
示例#21
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow) {
  ui->setupUi(this);

  QFile styleFile(":/style.css");
  styleFile.open(QFile::ReadOnly);
  QString styleSheet = QLatin1String(styleFile.readAll());
  qApp->setStyleSheet(styleSheet);

  QPixmap window_icon;
  QFile iconFile(":/icon.png");
  iconFile.open(QFile::ReadOnly);
  QByteArray icon_data = iconFile.readAll();
  window_icon.loadFromData(icon_data);
  qApp->setWindowIcon(QIcon(window_icon));

  awesome = new QtAwesome(qApp);
  settings = new Settings(this);
  window_watcher = new WindowWatcher(this);
  anitomy = new AnitomyWrapper();
  event_timer = new QTimer(this);
  watch_timer = new QTimer(this);
  uptime_timer = new QElapsedTimer;
  progress_bar = new QProgressBar(ui->statusBar);
  over = new Overlay(this);
  torrent_refresh_time = 0;
  user_refresh_time =
      settings->getValue(Settings::UserRefreshTime, D_USER_REFRESH_TIME)
          .toInt();
  download_rule = 0;
  download_count = 0;
  hasUser = false;

  uptime_timer->start();
  watch_timer->setSingleShot(true);

  awesome->initFontAwesome();

  bool check_for_updates =
      settings->getValue(Settings::CheckUpdates, D_CHECK_FOR_UPDATES).toBool();

  if (check_for_updates) {
    connect(FvUpdater::sharedUpdater(), &FvUpdater::restartRequested,
            [&]() {  // NOLINT
              QString app = QApplication::applicationFilePath();
              QStringList arguments = QApplication::arguments();
              QString wd = QDir::currentPath();
              QProcess::startDetached(app, arguments, wd);
              elegantClose(true);
            });

    FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
  }

  QFont font = ui->listTabs->tabBar()->font();
  font.setCapitalization(QFont::Capitalize);
  ui->listTabs->tabBar()->setFont(font);

  int currentYear = QDate::currentDate().year();
  int lowerYear = currentYear - 10;

  while (currentYear > lowerYear) {
    ui->comboYear->addItem(QString::number(currentYear));
    currentYear--;
  }

  QWidget *container = new QWidget(ui->scrollArea);
  layout = new FlowLayout(container);
  ui->scrollArea->setWidget(container);
  container->setLayout(layout);

  QWidget *container2 = new QWidget(ui->scrollArea_2);
  layout2 = new FlowLayout(container2);
  layout2->disableSort();
  ui->scrollArea_2->setWidget(container2);
  container2->setLayout(layout2);

  QVariantMap black;
  black.insert("color", QColor(0, 0, 0));
  black.insert("color-active", QColor(0, 0, 0));
  black.insert("color-disabled", QColor(0, 0, 0));
  black.insert("color-selected", QColor(0, 0, 0));

  ui->airingButton->setIcon(awesome->icon(fa::clocko, black));
  ui->torrentsButton->setIcon(awesome->icon(fa::rss, black));
  ui->animeButton->setIcon(awesome->icon(fa::bars, black));
  ui->seasonsButton->setIcon(awesome->icon(fa::th, black));
  ui->statisticsButton->setIcon(awesome->icon(fa::piechart, black));

  ui->tabWidget->tabBar()->hide();
  ui->tabWidget->setCurrentIndex(UserTabs::tAnime);
  ui->listTabs->setCurrentIndex(0);

  ui->statusBar->addWidget(progress_bar);
  ui->statusBar->layout()->setContentsMargins(1, 0, 0, 0);
  progress_bar->setRange(0, 100);
  progress_bar->setValue(5);
  progress_bar->setFormat("Authorizing");

  QSettings s;
  restoreGeometry(s.value("mainWindowGeometry").toByteArray());
  restoreState(s.value("mainWindowState").toByteArray());

  connect(&user_future_watcher, SIGNAL(finished()), SLOT(userLoaded()));
  connect(&user_list_future_watcher, SIGNAL(finished()),
          SLOT(userListLoaded()));

  connect(ui->animeButton, SIGNAL(clicked()), SLOT(showAnimeTab()));
  connect(ui->airingButton, SIGNAL(clicked()), SLOT(showAiringTab()));
  connect(ui->torrentsButton, SIGNAL(clicked()), SLOT(showTorrentsTab()));
  connect(ui->seasonsButton, SIGNAL(clicked()), SLOT(showBrowseTab()));
  connect(ui->actionSettings, SIGNAL(triggered()), SLOT(showSettings()));
  connect(ui->statisticsButton, SIGNAL(clicked()), SLOT(showStatisticsTab()));

  connect(ui->actionExit, &QAction::triggered, [&, this]() {  // NOLINT
    this->elegantClose();
  });

  connect(ui->actionAbout, &QAction::triggered, [&, this]() {  // NOLINT
    About *about = new About(this);
    about->show();
  });

  connect(ui->actionHelp, &QAction::triggered, [&, this]() {  // NOLINT
    QDesktopServices::openUrl(QUrl("http://app.shinjiru.me/support.php"));
  });

  connect(ui->actionRL, &QAction::triggered, [&, this]() {  // NOLINT
    loadUser();
  });

  connect(ui->actionAS, &QAction::triggered, [&]() {  // NOLINT
    SearchPanel *sp = new SearchPanel(this);
    sp->show();
  });

  connect(ui->actionARR, &QAction::triggered, [&, this]() {  // NOLINT
    SettingsDialog *s = new SettingsDialog(this);
    s->showSmartTitles();

    connect(s, &QDialog::accepted, [&, this]() {  // NOLINT
      Settings set;

      toggleAnimeRecognition(
          set.getValue(Settings::AnimeRecognitionEnabled, D_ANIME_RECOGNITION)
              .toBool());

      torrents_enabled =
          set.getValue(Settings::TorrentsEnabled, D_TORRENTS_ENABLED).toBool();

      reloadSmartTitles();
      reloadRules();
    });
  });

  connect(qApp, SIGNAL(aboutToQuit()), SLOT(elegantClose()));

  connect(ui->actionVAL, SIGNAL(triggered()), SLOT(viewAnimeList()));
  connect(ui->actionVD, SIGNAL(triggered()), SLOT(viewDashboard()));
  connect(ui->actionVP, SIGNAL(triggered()), SLOT(viewProfile()));
  connect(ui->actionEAR, SIGNAL(triggered(bool)),
          SLOT(toggleAnimeRecognition(bool)));
  connect(ui->actionExport, SIGNAL(triggered()), SLOT(exportListJSON()));
  connect(ui->actionUpdate, SIGNAL(triggered()), FvUpdater::sharedUpdater(),
          SLOT(CheckForUpdatesNotSilent()));

  connect(window_watcher, SIGNAL(title_found(QString)), SLOT(watch(QString)));
  connect(watch_timer, SIGNAL(timeout()), SLOT(updateEpisode()));
  connect(event_timer, SIGNAL(timeout()), SLOT(eventTick()));

  connect(ui->torrentTable, SIGNAL(customContextMenuRequested(QPoint)),
          SLOT(torrentContextMenu(QPoint)));
  connect(ui->torrentFilter, SIGNAL(textChanged(QString)),
          SLOT(filterTorrents(QString)));
  connect(ui->chkHideUnknown, SIGNAL(toggled(bool)),
          SLOT(filterTorrents(bool)));
  connect(ui->refreshButton, SIGNAL(clicked()), SLOT(refreshTorrentListing()));

  connect(ui->actionEAR, SIGNAL(toggled(bool)), SLOT(applyEAR()));

  connect(ui->tabWidget, &QTabWidget::currentChanged, [&, this](  // NOLINT
                                                          int tab) {
    if (tab != 0) {
      this->over->removeDrawing("blank_table");
      this->over->removeDrawing("no anime");
      ui->listTabs->show();
      ui->listFilterLineEdit->show();
    } else {
      this->filterList(3);

      if (hasUser && (User::sharedUser()->getAnimeList().count() == 0)) {
        this->addNoAnimePrompt();
      }
    }
  });

  ui->actionEAR->setChecked(
      settings->getValue(Settings::AnimeRecognitionEnabled, D_ANIME_RECOGNITION)
          .toBool());

  this->toggleAnimeRecognition(ui->actionEAR->isChecked());

  QString genrelist =
      "Action, Adult, Adventure, Cars, Comedy, Dementia, Demons, Doujinshi, "
      "Drama, Ecchi, Fantasy, Game, Gender Bender, Harem, Hentai, Historical, "
      "Horror, Josei, Kids, Magic, Martial Arts, Mature, Mecha, Military, "
      "Motion Comic, Music, Mystery, Mythological , Parody, Police, "
      "Psychological, Romance, Samurai, School, Sci-Fi, Seinen, Shoujo, Shoujo "
      "Ai, Shounen, Shounen Ai, Slice of Life, Space, Sports, Super Power, "
      "Supernatural, Thriller, Tragedy, Vampire, Yaoi, Yuri";
  QStringList genres = genrelist.split(", ");

  for (QString genre : genres) {
    QCheckBox *chk = new QCheckBox();

    chk->setText(genre);
    chk->setTristate(true);

    ui->genreList->addWidget(chk);
  }

  connect(ui->listFilterLineEdit, SIGNAL(textChanged(QString)),
          SLOT(filterList(QString)));
  connect(ui->listFilterLineEdit, SIGNAL(returnPressed()), SLOT(showSearch()));
  connect(ui->listTabs, SIGNAL(currentChanged(int)), SLOT(filterList(int)));

  connect(ui->browseButton, SIGNAL(clicked()), SLOT(loadBrowserData()));

  this->show();
  createActions();
  initTray();
  trayIcon->show();

  int result = API::sharedAPI()->verifyAPI();

  if (result == AniListAPI::OK) {
    connect(API::sharedAPI()->sharedAniListAPI(), &AniListAPI::access_granted,
            [&, this]() {  // NOLINT
              progress_bar->setValue(10);
              progress_bar->setFormat("Access granted");
              loadUser();

              event_timer->start(1000);
            });

    connect(API::sharedAPI()->sharedAniListAPI(), &AniListAPI::access_denied,
            [&, this](QString error) {  // NOLINT
              qCritical() << error;

              if (isVisible()) {
                QMessageBox::critical(this, "Shinjiru", tr("Error: ") + error);
              }
            });
  } else if (result == AniListAPI::NO_CONNECTION) {
    qDebug() << "Starting Shinjiru in offline mode";
    hasUser = User::sharedUser()->loadLocal();
  }

  reloadRules();
}
示例#22
0
//stdin and stdout for interapplication communication
int main(int argc, char *argv[])
{
    QSemaphore* wait4CleanupDone = new QSemaphore(1);
    int r;
    if(argc>2) {
    if(std::string(argv[1]).compare("Server") == 0) {
       //Standard Server Mode
       QCoreApplication a(argc, argv);
       OSCthulhuServer* server = new OSCthulhuServer(atoi(argv[2]),QString(argv[3]));
       r = a.exec();
       wait4CleanupDone->acquire();
   } else if(std::string(argv[1]).compare("daemon") == 0) {
    #if defined(__WIN32__) || defined(WIN32)

    #else
       //Daemon Server Mode
       /* Our process ID and Session ID */
              pid_t pid, sid;

              /* Fork off the parent process */
              pid = fork();
              if (pid < 0) {
                      exit(EXIT_FAILURE);
              }
              /* If we got a good PID, then
                 we can exit the parent process. */
              if (pid > 0) {
                      exit(EXIT_SUCCESS);
              }

              /* Change the file mode mask */
              umask(0);

              /* Open any logs here */

              /* Create a new SID for the child process */
              sid = setsid();
              if (sid < 0) {
                      /* Log the failure */
                      exit(EXIT_FAILURE);
              }

              /* Change the current working directory */
              if ((chdir("/")) < 0) {
                      /* Log the failure */
                      exit(EXIT_FAILURE);
              }

              /* Close out the standard file descriptors */
              close(STDIN_FILENO);
              close(STDOUT_FILENO);
              close(STDERR_FILENO);

       QCoreApplication a(argc, argv);
       OSCthulhuServer* server = new OSCthulhuServer(atoi(argv[2]),QString(argv[3]));
       r = a.exec();
       wait4CleanupDone->acquire();
       exit(EXIT_SUCCESS);
       #endif
   }

   } else {
       //Client Mode

       QApplication a(argc, argv);
       a.setApplicationName("OSCthulhu");
       a.setApplicationVersion("2.0a");
       a.setOrganizationName("Curtis McKinney");
       a.setOrganizationDomain("curtismckinney.com");
       QFile styleFile(":/style/gui/cthulhuStyleSheet.qss");
       if(styleFile.open(QFile::ReadOnly))
       {
           QString styleSheet = QLatin1String(styleFile.readAll());
           qApp->setStyleSheet(styleSheet);
       }
       //a.setStyle(new QPlastiqueStyle);

       QSettings* settings = new QSettings();
       OSCthulhuClient* client = new OSCthulhuClient(
                   settings->value("serverAddress",QVariant("127.0.0.1")).toString(),
                   settings->value("serverPassword",QVariant("lagpass")).toString(),
                   settings->value("userName",QVariant("Hatchling")).toString(),
                   settings->value("userPassword",QVariant("fakePass")).toString(),
                   settings->value("serverPort",QVariant(32242)).toInt(),
                   settings->value("clientPort",QVariant(32243)).toInt(),
                   settings->value("appPort",QVariant(32244)).toInt(),
                   wait4CleanupDone,
                   settings
       );

       QObject::connect(&a, SIGNAL(aboutToQuit()), client, SLOT(handleQuit()));
       r = a.exec();
       wait4CleanupDone->acquire();
    }
    return r;
}
示例#23
0
void reloadStyle() {
    QFile styleFile(":/style.qss");
    styleFile.open(QFile::ReadOnly);
    qApp->setStyleSheet(styleFile.readAll());
}
示例#24
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // load and set style from resources
    QFile styleFile(":/styles/default.style");
    styleFile.open(QFile::ReadOnly | QFile::Text);
    QString style(styleFile.readAll());
    styleFile.close();

    qDebug() << style;
    qApp->setStyleSheet(style);

    // init values fo images
    QColor c(255, 255, 255, 0);
    QSize s = ui->image1_scrollArea->viewport()->size();
    image1 = new ImageWrapper(s, c);
    image2 = new ImageWrapper(s, c);
    imager = new ImageWrapper(":/images/images/monkey.png");
    image1t2 = 0;
    image2t1 = 0;

    image1_ready = image2_ready = false;

    image1_widget = new ImageHighlight(ui->image1_scrollArea, image1);
    image1_widget->setHighlight(false);

    image2_widget = new ImageHighlight(ui->image2_scrollArea, image2);
    image2_widget->setHighlight(false);

    ui->image1_scrollArea->setWidget(image1_widget);
    ui->image1_scrollArea->setWidgetResizable(false);

    ui->image2_scrollArea->setWidget(image2_widget);
    ui->image2_scrollArea->setWidgetResizable(false);

    // signals connect
    connect(imager, SIGNAL(update()), this, SLOT(slot_imager_redraw()) );
    connect( ui->actionClear_all, SIGNAL(triggered()), this, SLOT(slot_clear_all()) );

    connect( image1, SIGNAL(newSegment(QPair<QPointF,QPointF>&)), this, SLOT(slot_image1_newSegment(QPair<QPointF,QPointF>&)) );
    connect( image2, SIGNAL(newSegment(QPair<QPointF,QPointF>&)), this, SLOT(slot_image2_newSegment(QPair<QPointF,QPointF>&)) );

    connect( image1, SIGNAL(update()), this, SLOT(slot_image1_update()) );
    connect( image2, SIGNAL(update()), this, SLOT(slot_image2_update()) );

    slot_imager_redraw();

    progress = new QProgressBar(this);
    progress->setMaximum(100);
    progress->setValue(0);
    progress->setVisible(false);
    ui->statusBar->addWidget(progress, 1);

    play_timer = new QTimer();
    connect( play_timer, SIGNAL(timeout()), this, SLOT(slot_play_timer_timeout()) );

    isRecording = false;
    isRepeating = false;
    this->rec_output = 0;

    this->outside_color = QColor(255,255,255);
    ui->outside_color_button->setStyleSheet("background-color: #fff;");

}
示例#25
0
void PreferencesDialog::initializePostSettings()
{
    //theme
    int size = m_preferences->value("ThemeNumber",0).toInt();
    if(size>0)
    {
        for(int i = 0; i< size; ++i)
        {
            QString name = m_preferences->value(QString("Theme_%1_name").arg(i),QString()).toString();
            QPalette pal = m_preferences->value(QString("Theme_%1_palette").arg(i),QPalette()).value<QPalette>();
            QString style = m_preferences->value(QString("Theme_%1_stylename").arg(i),"fusion").toString();
            QColor color = m_preferences->value(QString("Theme_%1_bgColor").arg(i),QColor(GRAY_SCALE,GRAY_SCALE,GRAY_SCALE)).value<QColor>();
            QString path = m_preferences->value(QString("Theme_%1_bgPath").arg(i),"").toString();
            int pos = m_preferences->value(QString("Theme_%1_bgPosition").arg(i),0).toInt();
            QString css = m_preferences->value(QString("Theme_%1_css").arg(i),"").toString();
            bool isRemovable = m_preferences->value(QString("Theme_%1_removable").arg(i),false).toBool();

            RolisteamTheme* tmp = new RolisteamTheme(pal,name,css,QStyleFactory::create(style),path,pos,color,isRemovable);
            m_themes.append(tmp);
            // m_preferences->registerValue(QString("Theme_%1_css").arg(i),tmp->getName());
        }
    }
    else //theme provided by default
    {
        //normal
        m_themes.append(new RolisteamTheme(QPalette(),tr("default"),"",QStyleFactory::create("fusion"),":/resources/icons/workspacebackground.bmp",0,QColor(GRAY_SCALE,GRAY_SCALE,GRAY_SCALE),false));

        //DarkOrange
        QFile styleFile(":/stylesheet/resources/stylesheet/darkorange.qss");
        styleFile.open(QFile::ReadOnly);
        QByteArray bytes = styleFile.readAll();
        QString css(bytes);
        m_themes.append(new RolisteamTheme(QPalette(),tr("darkorange"),css,QStyleFactory::create("fusion"),":/resources/icons/workspacebackground.bmp",0,QColor(GRAY_SCALE,GRAY_SCALE,GRAY_SCALE),false));

        //DarkFusion
        QPalette palette;
        palette.setColor(QPalette::Window, QColor(53,53,53));
        palette.setColor(QPalette::WindowText, Qt::white);
        palette.setColor(QPalette::Base, QColor(15,15,15));
        palette.setColor(QPalette::AlternateBase, QColor(53,53,53));
        palette.setColor(QPalette::ToolTipBase, Qt::white);
        palette.setColor(QPalette::ToolTipText, Qt::white);
        palette.setColor(QPalette::Text, Qt::white);
        palette.setColor(QPalette::Button, QColor(53,53,53));
        palette.setColor(QPalette::ButtonText, Qt::white);
        palette.setColor(QPalette::BrightText, Qt::red);

        palette.setColor(QPalette::Highlight, QColor(142,45,197).lighter());
        palette.setColor(QPalette::HighlightedText, Qt::black);
        palette.setColor(QPalette::Disabled, QPalette::Text, Qt::darkGray);
        palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::darkGray);

        m_themes.append(new RolisteamTheme(palette,tr("darkfusion"),"",QStyleFactory::create("fusion"),":/resources/icons/workspacebackground.bmp",0,QColor(GRAY_SCALE,GRAY_SCALE,GRAY_SCALE),false));
    }
    ui->m_themeComboBox->clear();

    foreach (RolisteamTheme* theme, m_themes)
    {
        ui->m_themeComboBox->addItem(theme->getName());
        if(!theme->isRemovable())
        {
            ui->m_themeComboBox->setItemIcon(ui->m_themeComboBox->count()-1,QIcon(":/resources/icons/lock.png"));
        }

    }