Пример #1
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    QTextCodec *utfcodec = QTextCodec::codecForName("UTF-8"); //qt4
    QTextCodec::setCodecForTr(utfcodec);
    QTextCodec::setCodecForCStrings(utfcodec);
dozvilNaVyhid=0;

    m_tray_icon = new QSystemTrayIcon(QIcon(":/new/emulator.png"), this);


     QAction *another_action = new QAction( "Показати/Сховати", m_tray_icon );
     another_action->setIcon(QIcon(":/new/emulator.png"));
     connect( another_action, SIGNAL(triggered()), this, SLOT(showHide()) );

     QAction *set_action = new QAction( "Налаштування", m_tray_icon );
     set_action->setIcon(QIcon(":/new/sett.png"));
     connect( set_action, SIGNAL(triggered()), this, SLOT(settigsDialog()) );


     QAction *quit_action = new QAction( "Вихід", m_tray_icon );
     quit_action->setIcon(QIcon(":/new/exit.png"));
     connect( quit_action, SIGNAL(triggered()), this, SLOT(dozvilNaclose()) );

     QMenu *tray_icon_menu = new QMenu;
     tray_icon_menu->addAction( another_action );
     tray_icon_menu->addAction( set_action );
     tray_icon_menu->addAction( quit_action );

     m_tray_icon->setContextMenu( tray_icon_menu );

     connect( m_tray_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));

     m_tray_icon->show();

     myThreadTimer.setSingleShot(1);
     myThreadTimer.setInterval(3000);


     myUPS=new UPSMonThread(this);

    connect(myUPS, SIGNAL(vyvidDanyh(QStringList)), this, SLOT(vyvidDanyh(QStringList)));
    connect(myUPS, SIGNAL(vyvidMess(QString)), this, SLOT(vyvidPovidomlen(QString)));
    connect(myUPS, SIGNAL(vyvidBattStatus(QString)), this, SLOT(vyvidBattStatus(QString)));
    connect(myUPS, SIGNAL(terminated()), &myThreadTimer, SLOT(start()));
    connect(myUPS, SIGNAL(offcomp()), this, SLOT(dozvilNaclose()));
    connect(&myThreadTimer, SIGNAL(timeout()), this, SLOT(onTimerOut()));

    loadSett();
    myUPS->changeBatAndWaitTime(waitTime, battVal);
    myThreadTimer.start();
//    this->hide();
    QTimer::singleShot(0, this, SLOT(showHide()));

//    connect(this, SIGNAL())

}
Пример #2
0
void QgsMapToolShowHideLabels::showHideLabels( QMouseEvent *e )
{
  QgsMapLayer *layer = mCanvas->currentLayer();
  QgsVectorLayer *vlayer = dynamic_cast<QgsVectorLayer *>( layer );
  if ( !vlayer )
    return;

  bool doHide = e->modifiers() & Qt::ShiftModifier;
  QString editTxt = doHide ? tr( "Hid labels" ) : tr( "Showed labels" );
  vlayer->beginEditCommand( editTxt );

  bool labelChanged = false;
  if ( doHide )
  {
    QList<QgsLabelPosition> positions;
    if ( selectedLabelFeatures( vlayer, positions ) )
    {
      for ( const QgsLabelPosition &pos : qgis::as_const( positions ) )
      {
        if ( showHide( pos, false ) )
          labelChanged = true;
      }
    }
  }
  else
  {
    QgsFeatureIds fids;
    if ( selectedFeatures( vlayer, fids ) )
    {
      for ( const QgsFeatureId &fid : qgis::as_const( fids ) )
      {
        QgsLabelPosition pos;
        pos.featureId = fid;
        pos.layerID = vlayer->id();

        // we want to show labels...
        pos.isDiagram = false;
        if ( showHide( pos, true ) )
          labelChanged = true;

        // ... and diagrams
        pos.isDiagram = true;
        if ( showHide( pos, true ) )
          labelChanged = true;
      }
    }
  }

  if ( labelChanged )
  {
    vlayer->endEditCommand();
    vlayer->triggerRepaint();
  }
  else
  {
    vlayer->destroyEditCommand();
  }
}
Пример #3
0
void QgsMapToolShowHideLabels::showHideLabels( QMouseEvent * e )
{
  QgsMapLayer* layer = mCanvas->currentLayer();

  QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( layer );
  if ( !vlayer )
  {
    QgsDebugMsg( "Failed to cast label layer to vector layer" );
    return;
  }
  if ( !vlayer->isEditable() )
  {
    QgsDebugMsg( "Vector layer not editable, skipping label" );
    return;
  }

  bool doHide = e->modifiers() & Qt::ShiftModifier;
  bool labelChanged = false;
  QString editTxt = doHide ? tr( "Hid labels" ) : tr( "Showed labels" );
  vlayer->beginEditCommand( editTxt );

  if ( !doHide )
  {
    QgsDebugMsg( "Showing labels operation" );

    QgsFeatureIds selectedFeatIds;
    if ( !selectedFeatures( vlayer, selectedFeatIds ) )
    {
      vlayer->destroyEditCommand();
      return;
    }

    QgsDebugMsg( "Number of selected labels or features: " + QString::number( selectedFeatIds.size() ) );

    if ( selectedFeatIds.isEmpty() )
    {
      vlayer->destroyEditCommand();
      return;
    }

    Q_FOREACH ( QgsFeatureId fid, selectedFeatIds )
    {
      mCurrentLabel.pos.featureId = fid;

      mCurrentLabel.pos.isDiagram = false;
      bool labChanged = showHide( vlayer, true );

      mCurrentLabel.pos.isDiagram = true;
      bool diagChanged = showHide( vlayer, true );

      if ( labChanged || diagChanged )
      {
        // TODO: highlight features (maybe with QTimer?)
        labelChanged = labelChanged || true;
      }
    }
Пример #4
0
void QTlen::activeTrayIcon()
{
	if( !v_tray )
	{
		trayPopup = new QPopupMenu( this );
		//trayPopup->insertItem( tr("Receive event"), this, SLOT( showHide() ), 0, 0 );
		//trayPopup->setItemVisible( 0, false );
		//trayPopup->insertSeparator();
		trayPopup->insertItem( tr("Hide"), this, SLOT( showHide() ), 0, 1 );
		trayPopup->insertItem( tr("Set status"), statusPopup );
		trayPopup->insertSeparator();
		trayPopup->insertItem( QIconSet( takePixmap("exit") ), tr("Exit program"), this, SLOT( quit() ) );
		
		tray = new TrayIcon( takePixmap("offline"), "QTlen<br>" + tr( "Offline" ), trayPopup, this );
		
		updateTrayIcon();
		
		tray->show();
		
		v_tray = true;
		
		v_quit = false;
		
		connect( tray, SIGNAL( clicked( const QPoint&, int) ),
			this, SLOT( trayClicked( const QPoint&, int) ) );
		connect( tray, SIGNAL( doubleClicked( const QPoint& ) ),
			this, SLOT( trayDoubleClicked( const QPoint& ) ) );
		connect( tray, SIGNAL( closed() ),
			this, SLOT( trayClosed() ) );
	}
Пример #5
0
void MainWindow::initGlobaShortcut()
{
    _shortcutDef = QString("Alt+S");
    _hotkeyHandle.setShortcut( QKeySequence(_shortcutDef) );
    _hotkeyHandle.setEnabled(true);
    connect( &_hotkeyHandle, SIGNAL(activated()), this, SLOT(showHide()) );
}
/* This is the main entry point from Matlab: */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
{
    int show = 1;
    
    mexAtExit(exitfunc);    
    if (nrhs > 0) show = (int) mxGetScalar(prhs[0]);
    showHide(show);
    return;
}
Пример #7
0
Dialog::Dialog(QWidget *parent) :
    QDialog(parent, Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint),
    ui(new Ui::Dialog),
    mSettings(new RazorSettings("razor-runner", this)),
    mGlobalShortcut(new QxtGlobalShortcut(this))
{
    ui->setupUi(this);
    setWindowTitle("Razor Runner");

    connect(RazorSettings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(update()));

    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));

    connect(mSettings, SIGNAL(settingsChanged()), this, SLOT(applySettings()));

    ui->commandEd->installEventFilter(this);

    connect(ui->commandEd, SIGNAL(textChanged(QString)), this, SLOT(setFilter(QString)));
    connect(ui->commandEd, SIGNAL(returnPressed()), this, SLOT(runCommand()));


    mCommandItemModel = new CommandItemModel(this);
    ui->commandList->installEventFilter(this);
    ui->commandList->setModel(mCommandItemModel);
    ui->commandList->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->commandList, SIGNAL(clicked(QModelIndex)), this, SLOT(runCommand()));
    setFilter("");

    ui->commandList->setItemDelegate(new HtmlDelegate(QSize(32, 32), ui->commandList));
    connect(mGlobalShortcut, SIGNAL(activated()), this, SLOT(showHide()));

    // Popup menu ...............................
    QAction *a = new QAction(XdgIcon::fromTheme("configure"), tr("Configure razor-runner"), this);
    connect(a, SIGNAL(triggered()), this, SLOT(showConfigDialog()));
    addAction(a);
    
    a = new QAction(XdgIcon::fromTheme("edit-clear-history"), tr("Clear razor-runner History"), this);
    connect(a, SIGNAL(triggered()), mCommandItemModel, SLOT(clearHistory()));
    addAction(a);

    mPowerManager = new PowerManager(this);
    addActions(mPowerManager->availableActions());
    mScreenSaver = new ScreenSaver(this);
    addActions(mScreenSaver->availableActions());

    setContextMenuPolicy(Qt::ActionsContextMenu);
    
    QMenu *menu = new QMenu(this);
    menu->addActions(actions());
    ui->actionButton->setMenu(menu);
    ui->actionButton->setIcon(XdgIcon::fromTheme("configure"));
    // End of popup menu ........................

    applySettings();
    resize(mSettings->value("dialog/width", 400).toInt(), size().height());
}
Пример #8
0
bool QmlWindow::event(QEvent *event)
{
    if (event->type() == QEvent::Close && !m_exiting && m_persistent) {
        qDebug() << "Event exit";
        showHide();
        event->setAccepted(false);
        return false;
    }
    return QWidget::event(event);
}
Пример #9
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    trIcon = new QSystemTrayIcon();
    trIcon->setIcon(QIcon(":/img/icon.png"));
    trIcon->show();

    connect(trIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(showHide(QSystemTrayIcon::ActivationReason)));
}
Пример #10
0
void MainWindow::setShortcuts() {
    // Global shortcuts
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_W), this, SLOT(showHide()), "Show/Hide");
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_P), this, SLOT(showHide()), "Show/Hide");
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_X), &player_, SLOT(play()), "Play");
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_C), &player_, SLOT(playPause()),
                      "Play/Pause");
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_A), &player_, SLOT(prev()), "Prev");
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_Z), &player_, SLOT(next()), "Next");
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_V), &player_, SLOT(stop()), "Stop");
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_PageUp), this, SLOT(increaseVolume()),
                      "Increase volume");
    addGlobalShortcut(QKeySequence(Qt::META + Qt::Key_PageDown), this, SLOT(decreaseVolume()),
                      "Decrease volume");

    // App shortcuts
    addShortcut(QKeySequence(Qt::CTRL + Qt::Key_J), SLOT(focusFilter()));
    //     addShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), SLOT(removeActivePlaylist()));
    addShortcut(QKeySequence(Qt::CTRL + Qt::Key_D), SLOT(showHideConsole()),
                Qt::ApplicationShortcut);
}
Пример #11
0
levelChooser::levelChooser(QWidget *parent) : QWidget(parent) {
   dSelected = false;
   diffSelector = new difficultySelector(this);
   levSelector = new levelSelector(this);
   connect(diffSelector, SIGNAL(difficultySelected(int)), levSelector, SLOT(difficultySelected(int)));
   connect(diffSelector, SIGNAL(difficultySelected(int)), this, SLOT(diffSelected(int)));
   connect(levSelector, SIGNAL(levelSelected(QString)), this, SIGNAL(levelSelected(QString)));
   connect(levSelector, SIGNAL(reset()), this, SLOT(reset()));
   
   connect(levSelector, SIGNAL(backButton()), this, SLOT(backButton()));
   showHide();
}
Пример #12
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: showHide(); break;
        case 1: iconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Пример #13
0
Dialog::Dialog(QWidget *parent) :
    QDialog(parent, Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint),
    ui(new Ui::Dialog),
    mSettings(new RazorSettings("razor-runner", this)),
    mGlobalShortcut(new QxtGlobalShortcut(this)),
    mCommandItemModel(new CommandItemModel(this))
{
    ui->setupUi(this);
    setStyleSheet(razorTheme->qss("razor-runner/razor-runner"));
    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));

    connect(mSettings, SIGNAL(settigsChanged()), this, SLOT(applySettings()));


    ui->commandEd->installEventFilter(this);
    ui->commandEd->setInsertPolicy(QComboBox::NoInsert);
    ui->commandEd->setCompleter(0);

    connect(ui->commandEd, SIGNAL(textChanged(QString)), this, SLOT(setFilter(QString)));
    connect(ui->commandEd->lineEdit(), SIGNAL(returnPressed()), this, SLOT(runCommand()));


    ui->commandList->installEventFilter(this);
    ui->commandList->setModel(mCommandItemModel);
    ui->commandList->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->commandList, SIGNAL(clicked(QModelIndex)), this, SLOT(runCommand()));
    setFilter("");

    ui->commandList->setItemDelegate(new HtmlDelegate(QSize(32, 32), ui->commandList));
    connect(mGlobalShortcut, SIGNAL(activated()), this, SLOT(showHide()));

    // Popup menu ...............................
    QAction *a = new QAction(XdgIcon::fromTheme("configure"), tr("Configure razor-runner"), this);
    connect(a, SIGNAL(triggered()), this, SLOT(showConfigDialog()));
    addAction(a);

    setContextMenuPolicy(Qt::ActionsContextMenu);
    // End of popup menu ........................

    applySettings();
    resize(mSettings->value("dialog/width", 400).toInt(), size().height());

    XdgIcon::setThemeName(RazorSettings::globalSettings()->value("icon_theme").toString());
    connect(RazorSettings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(update()));
}
Пример #14
0
//------------------------------------------------------------------------------
void MainWindow::createConnects()
{
    //tray
    connect(trIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(showHide(QSystemTrayIcon::ActivationReason)));

    // menu file
    connect(ui->actionFileQuit, SIGNAL(triggered()), this, SLOT(close()));

    // menu about
    connect(ui->actionAboutAbout, SIGNAL(triggered()), about, SLOT(show()));
    connect(ui->actionAboutAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->actionAboutHomeSite, SIGNAL(triggered()), this, SLOT(slot_aboutOpenSite()));

    // buttons
    connect(ui->pBBrowseOutputFolder, SIGNAL(clicked()), SLOT(slot_selectOutputFolder()));
    connect(ui->pBDownload, SIGNAL(clicked()), SLOT(slot_download()));
    connect(ui->pBAddUrlsFromFile, SIGNAL(clicked()), SLOT(slot_addUrlFromFile()));
    connect(ui->pBAddUrl, SIGNAL(clicked()), SLOT(slot_addUrlToList()));
}
Пример #15
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    habranews_new=0;
    habrapes_new=0;
    habraqa_new=0;
    parsing=0;

    templatehtml["top"]=QString::fromUtf8("<html><head><style type=\"text/css\"> DIV.brd { background: #eeeeee; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:0px; padding:5px; } </style></head><body>");
    templatehtml["bottom"]=QString::fromUtf8("</body></html>");
    templatehtml["template"]=QString::fromUtf8("<div class=\"brd\">&nbsp;&nbsp;&nbsp;<b>%5</b>. <a href=\"%1\" style=\"text-decoration: none; font-size:11px; color: #000\"><font face=\"Arial\">%2</font></a> (<b style=\"font-size:12px;\">%3</b>) <a href=\"http://habrahabr.ru/users/%4/\" style=\"font-size:9px; color: #000\">%4</a> </div>");
    templatehtml["templatepes"]=QString::fromUtf8("<div class=\"brd\">&nbsp;&nbsp;&nbsp;<b>%3</b>. <a href=\"%1\" style=\"text-decoration: none; font-size:11px; color: #000\"><font face=\"Arial\">%2</font></a></div>");

    trIcon = new QSystemTrayIcon();
    trIcon->setIcon(QIcon(":/img/icon.png"));
    trIcon->show();
    setWindowTitle(QObject::trUtf8("Habra-Tray"));
    setWindowIcon(QIcon(":/img/icon.png"));

    QMenu *Menu = new QMenu(this);
    QAction *quitAction1 = new QAction("HabraHabr.ru", this);
    connect(quitAction1, SIGNAL(triggered()), this, SLOT(habralink()));
    QAction *quitAction = new QAction("Quit", this);
    connect(quitAction, SIGNAL(triggered()), this, SLOT(closeEvent_re()));
    Menu->addAction(quitAction1);
    Menu->addSeparator();
    Menu->addAction(quitAction);
    trIcon->setContextMenu(Menu);

    this->updater_db();
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updater_db()));
    timer->start(60000);

    connect(trIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(showHide(QSystemTrayIcon::ActivationReason)));

}
Пример #16
0
void ActionGroup::init(bool header)
{
  m_foldStep = 0;

  myScheme = ActionPanelScheme::defaultScheme();

  QVBoxLayout *vbl = new QVBoxLayout();
  vbl->setMargin(0);
  vbl->setSpacing(0);
  setLayout(vbl);

  vbl->addWidget(myHeader);

  myGroup = new TaskGroup(this, header);
  vbl->addWidget(myGroup);

  myDummy = new QWidget(this);
  vbl->addWidget(myDummy);
  myDummy->hide();

  connect(myHeader, SIGNAL(activated()), this, SLOT(showHide()));
}
void exitfunc(void)
{
    showHide(1);
}
Пример #18
0
Dialog::Dialog(QWidget *parent) :
    QDialog(parent, Qt::Tool | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint),
    ui(new Ui::Dialog),
    mSettings(new LxQt::Settings("lxqt-runner", this)),
    mGlobalShortcut(0),
    mLockCascadeChanges(false),
    mConfigureDialog(0)
{
    ui->setupUi(this);
    setWindowTitle("LXQt Runner");
    setAttribute(Qt::WA_TranslucentBackground);

    connect(LxQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(update()));
    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
    connect(mSettings, SIGNAL(settingsChanged()), this, SLOT(applySettings()));

    ui->commandEd->installEventFilter(this);

    connect(ui->commandEd, SIGNAL(textChanged(QString)), this, SLOT(setFilter(QString)));
    connect(ui->commandEd, SIGNAL(returnPressed()), this, SLOT(runCommand()));

    mCommandItemModel = new CommandItemModel(this);
    ui->commandList->installEventFilter(this);
    ui->commandList->setModel(mCommandItemModel);
    ui->commandList->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->commandList, SIGNAL(clicked(QModelIndex)), this, SLOT(runCommand()));
    setFilter("");
    dataChanged();

    ui->commandList->setItemDelegate(new LxQt::HtmlDelegate(QSize(32, 32), ui->commandList));

    // Popup menu ...............................
    QAction *a = new QAction(XdgIcon::fromTheme("configure"), tr("Configure"), this);
    connect(a, SIGNAL(triggered()), this, SLOT(showConfigDialog()));
    addAction(a);

    a = new QAction(XdgIcon::fromTheme("edit-clear-history"), tr("Clear History"), this);
    connect(a, SIGNAL(triggered()), mCommandItemModel, SLOT(clearHistory()));
    addAction(a);

    mPowerManager = new LxQt::PowerManager(this);
    addActions(mPowerManager->availableActions());
    mScreenSaver = new LxQt::ScreenSaver(this);
    addActions(mScreenSaver->availableActions());

    setContextMenuPolicy(Qt::ActionsContextMenu);

    QMenu *menu = new QMenu(this);
    menu->addActions(actions());
    ui->actionButton->setMenu(menu);
    ui->actionButton->setIcon(XdgIcon::fromTheme("configure"));
    // End of popup menu ........................

    applySettings();

    connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(realign()));
    connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(realign()));
    connect(mGlobalShortcut, SIGNAL(activated()), this, SLOT(showHide()));
    connect(mGlobalShortcut, SIGNAL(shortcutChanged(QString,QString)), this, SLOT(shortcutChanged(QString,QString)));

    resize(mSettings->value("dialog/width", 400).toInt(), size().height());


    // TEST
    connect(mCommandItemModel, SIGNAL(layoutChanged()), this, SLOT(dataChanged()));
}
Пример #19
0
void ModalOverlay::toggleVisibility()
{
    showHide(layerIsVisible, true);
    if (!layerIsVisible)
        userClosed = true;
}
Пример #20
0
void ModalOverlay::closeClicked()
{
    showHide(true);
    userClosed = true;
}
Пример #21
0
/*////////////////////////////////////////////Start program//////////////////////////////////////////////*/
Krudio::Krudio(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Krudio)
{
    ui->setupUi(this);
    ui->waitMinute->hide();//Скрываем label загрузки буфера
    ceckBUFFtimer = new QTimer();//таймер для буферинга
    QDir(QDir::homePath()).mkdir(".krudio");
    //Иконка в трее
    trIcon = new QSystemTrayIcon();  //инициализируем объект
    trIcon->setIcon(QIcon::fromTheme("krudio",QIcon("/usr/share/icons/hicolor/48x48/apps/krudio.svg")));  //устанавливаем иконку
    trIcon->show();  //отображаем объект
    //При клике сворачивать или разворачивать окно
    connect(trIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(showHide(QSystemTrayIcon::ActivationReason)));
    //Создаем контекстное меню для иконки в трее, чтобы закрывать программу
    QMenu*   pmnu   = new QMenu("&Menu");
    pmnu->addAction("&Exit", this, SLOT(closeEV()));
    trIcon->setContextMenu(pmnu);
    //Иконка в трее

    //Подключение к базе
    QSqlDatabase dbase = QSqlDatabase::addDatabase("QSQLITE");
    fullPath=QDir::homePath()+"/.krudio/"+baseName;
    dbase.setDatabaseName(fullPath);
    if (!dbase.open()) {
        qDebug() << "Что-то пошло не так!";
        return;
    }
    //Подключение к базе

    QSqlQuery a_query;

    //Создаем таблицу со станциями
    QString str =
            "CREATE TABLE "+tableStationsName+" (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT, url TEXT);";
    bool b = a_query.exec(str);
    if (!b) {qDebug() << "Таблица со станциями уже существует.";}
    //Создаем таблицу со станциями

    //Создаем таблицу с настройками
    str = "CREATE TABLE "+tableSettingName+" (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, setting TEXT, value INTEGER);";
    b = a_query.exec(str);
    if (!b) {qDebug() << "Таблица с настройками уже существует.";}
    //Создаем таблицу с настройками

    //Проверяем какие настройки включены
    if (!a_query.exec("SELECT * FROM "+tableSettingName)) {qDebug() << "Не получается прочитать информацию с таблицы.";return;}
    QSqlRecord rec = a_query.record();//Записываем результ с выборки
    //Создаем переменные к которым будем присваивать значения из таблицы
    QString setting="",
            id="";
    int     value,
            colorIcons=-1,// -1 Настроек нет
            sizeIcon=-1;// -1 Настроек нет
    while (a_query.next()) {
        id = a_query.value(rec.indexOf("id")).toString();
        setting = a_query.value(rec.indexOf("setting")).toString();
        value = a_query.value(rec.indexOf("value")).toInt();
        //Если есть настройки цвета иконок, то добавляем в переменную значение
        if(setting=="color"){
            colorIcons=value;
        }
        //Если есть настройки размера иконок, то добавляем в переменную значение
        if(setting=="iconsize"){
            sizeIcon=value;
        }
    }
    //Сохраняем настройки если их нет
    QString str_insert;
    if(sizeIcon==-1){
        str_insert = "INSERT INTO "+tableSettingName+" (id, setting, value) VALUES (NULL, '%1', %2);";
        str = str_insert.arg("iconsize").arg(0);//32
        b = a_query.exec(str);
        if (!b) {qDebug() << "Данные не вставляются";}
        currentsizeIcon=0;
    }
    else{
        setsizeIcon(sizeIcon,false);
        currentsizeIcon=sizeIcon;
    }
    if(colorIcons==-1){
        //Добавляем настройку цвета по умолчанию
        str_insert = "INSERT INTO "+tableSettingName+" (id, setting, value) VALUES (NULL, '%1', %2);";
        str = str_insert.arg("color").arg(0);
        b = a_query.exec(str);
        if (!b) {qDebug() << "Данные не вставляются";}
        setcolorIcon(0,false);
        currentColorNumb=0;
    }else{
        setcolorIcon(colorIcons,false);
        currentColorNumb=colorIcons;
    }

    ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);//Включаем запрет на редактирование таблицы
    refreshTable();//Обновляем содержимое таблицы
}
Пример #22
0
void levelChooser::backButton() {
   dSelected = false;
   showHide();
}
Пример #23
0
void levelChooser::diffSelected(int) {
   dSelected = true;
   showHide();
}
Пример #24
0
void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) {
    if (reason == QSystemTrayIcon::Trigger) {
        showHide();
    }
}
Пример #25
0
void Widget::trayIconClicked(QSystemTrayIcon::ActivationReason reason)
{
    if( reason==QSystemTrayIcon::Trigger)
        showHide();
}